@@ -262,6 +262,7 @@ export class SuggestDetailsOverlay implements IOverlayWidget {
262262
263263 private _added : boolean = false ;
264264 private _anchorBox ?: dom . IDomNodePagePosition ;
265+ private _preferAlignAtTop : boolean = true ;
265266 private _userSize ?: dom . Dimension ;
266267 private _topLeft ?: TopLeftPosition ;
267268
@@ -315,7 +316,7 @@ export class SuggestDetailsOverlay implements IOverlayWidget {
315316
316317 this . _disposables . add ( this . widget . onDidChangeContents ( ( ) => {
317318 if ( this . _anchorBox ) {
318- this . _placeAtAnchor ( this . _anchorBox , this . _userSize ?? this . widget . size ) ;
319+ this . _placeAtAnchor ( this . _anchorBox , this . _userSize ?? this . widget . size , this . _preferAlignAtTop ) ;
319320 }
320321 } ) ) ;
321322 }
@@ -361,13 +362,14 @@ export class SuggestDetailsOverlay implements IOverlayWidget {
361362 }
362363 }
363364
364- placeAtAnchor ( anchor : HTMLElement ) {
365+ placeAtAnchor ( anchor : HTMLElement , preferAlignAtTop : boolean ) {
365366 const anchorBox = dom . getDomNodePagePosition ( anchor ) ;
366367 this . _anchorBox = anchorBox ;
367- this . _placeAtAnchor ( this . _anchorBox , this . _userSize ?? this . widget . size ) ;
368+ this . _preferAlignAtTop = preferAlignAtTop ;
369+ this . _placeAtAnchor ( this . _anchorBox , this . _userSize ?? this . widget . size , preferAlignAtTop ) ;
368370 }
369371
370- _placeAtAnchor ( anchorBox : dom . IDomNodePagePosition , size : dom . Dimension ) {
372+ _placeAtAnchor ( anchorBox : dom . IDomNodePagePosition , size : dom . Dimension , preferAlignAtTop : boolean ) {
371373 const bodyBox = dom . getClientArea ( document . body ) ;
372374
373375 const info = this . widget . getLayoutInfo ( ) ;
@@ -416,12 +418,22 @@ export class SuggestDetailsOverlay implements IOverlayWidget {
416418 height = maxHeight ;
417419 }
418420 let maxSize : dom . Dimension ;
419- if ( height <= placement . maxSizeTop . height ) {
420- alignAtTop = true ;
421- maxSize = placement . maxSizeTop ;
421+ if ( preferAlignAtTop ) {
422+ if ( height <= placement . maxSizeTop . height ) {
423+ alignAtTop = true ;
424+ maxSize = placement . maxSizeTop ;
425+ } else {
426+ alignAtTop = false ;
427+ maxSize = placement . maxSizeBottom ;
428+ }
422429 } else {
423- alignAtTop = false ;
424- maxSize = placement . maxSizeBottom ;
430+ if ( height <= placement . maxSizeBottom . height ) {
431+ alignAtTop = false ;
432+ maxSize = placement . maxSizeBottom ;
433+ } else {
434+ alignAtTop = true ;
435+ maxSize = placement . maxSizeTop ;
436+ }
425437 }
426438
427439 this . _applyTopLeft ( { left : placement . left , top : alignAtTop ? placement . top : bottom - height } ) ;
0 commit comments