@@ -27,9 +27,10 @@ import { HoverAnchor, HoverAnchorType, HoverRangeAnchor, IEditorHover, IEditorHo
27
27
import { MarkdownHoverParticipant } from 'vs/editor/contrib/hover/markdownHoverParticipant' ;
28
28
import { MarkerHoverParticipant } from 'vs/editor/contrib/hover/markerHoverParticipant' ;
29
29
import { InlineCompletionsHoverParticipant } from 'vs/editor/contrib/inlineCompletions/inlineCompletionsHoverParticipant' ;
30
- import { IContextKey } from 'vs/platform/contextkey/common/contextkey' ;
30
+ import { IContextKey , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
31
31
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
32
32
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
33
+ import { Context as SuggestContext } from 'vs/editor/contrib/suggest/suggest' ;
33
34
34
35
const $ = dom . $ ;
35
36
@@ -199,13 +200,14 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget, I
199
200
private _shouldFocus : boolean ;
200
201
private _colorPicker : ColorPickerWidget | null ;
201
202
private _renderDisposable : IDisposable | null ;
202
- private _preferBelow : boolean ;
203
+ private _preferAbove : boolean ;
203
204
204
205
constructor (
205
206
editor : ICodeEditor ,
206
207
private readonly _hoverVisibleKey : IContextKey < boolean > ,
207
208
@IInstantiationService instantiationService : IInstantiationService ,
208
209
@IKeybindingService private readonly _keybindingService : IKeybindingService ,
210
+ @IContextKeyService private readonly _contextKeyService : IContextKeyService ,
209
211
) {
210
212
super ( ) ;
211
213
@@ -251,7 +253,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget, I
251
253
this . _isChangingDecorations = false ;
252
254
this . _shouldFocus = false ;
253
255
this . _colorPicker = null ;
254
- this . _preferBelow = this . _editor . getOption ( EditorOption . hover ) . below ;
256
+ this . _preferAbove = this . _editor . getOption ( EditorOption . hover ) . above ;
255
257
256
258
this . _hoverOperation = new HoverOperation (
257
259
this . _computer ,
@@ -271,7 +273,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget, I
271
273
} ) ) ;
272
274
this . _register ( editor . onDidChangeConfiguration ( ( ) => {
273
275
this . _hoverOperation . setHoverTime ( this . _editor . getOption ( EditorOption . hover ) . delay ) ;
274
- this . _preferBelow = this . _editor . getOption ( EditorOption . hover ) . below ;
276
+ this . _preferAbove = this . _editor . getOption ( EditorOption . hover ) . above ;
275
277
} ) ) ;
276
278
this . _register ( TokenizationRegistry . onDidChange ( ( ) => {
277
279
if ( this . _isVisible && this . _lastAnchor && this . _messages . length > 0 ) {
@@ -368,15 +370,20 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget, I
368
370
369
371
public getPosition ( ) : IContentWidgetPosition | null {
370
372
if ( this . _isVisible ) {
373
+ let preferAbove = this . _preferAbove ;
374
+ if ( ! preferAbove && this . _contextKeyService . getContextKeyValue < boolean > ( SuggestContext . Visible . key ) ) {
375
+ // Prefer rendering above if the suggest widget is visible
376
+ preferAbove = true ;
377
+ }
371
378
return {
372
379
position : this . _showAtPosition ,
373
380
range : this . _showAtRange ,
374
- preference : this . _preferBelow ? [
375
- ContentWidgetPositionPreference . BELOW ,
381
+ preference : preferAbove ? [
376
382
ContentWidgetPositionPreference . ABOVE ,
383
+ ContentWidgetPositionPreference . BELOW ,
377
384
] : [
378
- ContentWidgetPositionPreference . ABOVE ,
379
385
ContentWidgetPositionPreference . BELOW ,
386
+ ContentWidgetPositionPreference . ABOVE ,
380
387
] ,
381
388
} ;
382
389
}
0 commit comments