@@ -262,6 +262,7 @@ export class SuggestDetailsOverlay implements IOverlayWidget {
262
262
263
263
private _added : boolean = false ;
264
264
private _anchorBox ?: dom . IDomNodePagePosition ;
265
+ private _preferAlignAtTop : boolean = true ;
265
266
private _userSize ?: dom . Dimension ;
266
267
private _topLeft ?: TopLeftPosition ;
267
268
@@ -315,7 +316,7 @@ export class SuggestDetailsOverlay implements IOverlayWidget {
315
316
316
317
this . _disposables . add ( this . widget . onDidChangeContents ( ( ) => {
317
318
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 ) ;
319
320
}
320
321
} ) ) ;
321
322
}
@@ -361,13 +362,14 @@ export class SuggestDetailsOverlay implements IOverlayWidget {
361
362
}
362
363
}
363
364
364
- placeAtAnchor ( anchor : HTMLElement ) {
365
+ placeAtAnchor ( anchor : HTMLElement , preferAlignAtTop : boolean ) {
365
366
const anchorBox = dom . getDomNodePagePosition ( anchor ) ;
366
367
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 ) ;
368
370
}
369
371
370
- _placeAtAnchor ( anchorBox : dom . IDomNodePagePosition , size : dom . Dimension ) {
372
+ _placeAtAnchor ( anchorBox : dom . IDomNodePagePosition , size : dom . Dimension , preferAlignAtTop : boolean ) {
371
373
const bodyBox = dom . getClientArea ( document . body ) ;
372
374
373
375
const info = this . widget . getLayoutInfo ( ) ;
@@ -416,12 +418,22 @@ export class SuggestDetailsOverlay implements IOverlayWidget {
416
418
height = maxHeight ;
417
419
}
418
420
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
+ }
422
429
} 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
+ }
425
437
}
426
438
427
439
this . _applyTopLeft ( { left : placement . left , top : alignAtTop ? placement . top : bottom - height } ) ;
0 commit comments