@@ -12,15 +12,13 @@ import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config
12
12
import { Range } from 'vs/editor/common/core/range' ;
13
13
import { IEditorContribution , IScrollEvent } from 'vs/editor/common/editorCommon' ;
14
14
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys' ;
15
- import { ILanguageService } from 'vs/editor/common/languages/language' ;
16
15
import { GotoDefinitionAtPositionEditorContribution } from 'vs/editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition' ;
17
16
import { HoverStartMode , HoverStartSource } from 'vs/editor/contrib/hover/browser/hoverOperation' ;
18
17
import { ContentHoverWidget , ContentHoverController } from 'vs/editor/contrib/hover/browser/contentHover' ;
19
18
import { MarginHoverWidget } from 'vs/editor/contrib/hover/browser/marginHover' ;
20
19
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility' ;
21
20
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
22
21
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry' ;
23
- import { IOpenerService } from 'vs/platform/opener/common/opener' ;
24
22
import { editorHoverBorder } from 'vs/platform/theme/common/colorRegistry' ;
25
23
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService' ;
26
24
import { HoverParticipantRegistry } from 'vs/editor/contrib/hover/browser/hoverTypes' ;
@@ -49,6 +47,11 @@ interface IHoverState {
49
47
activatedByDecoratorClick : boolean ;
50
48
}
51
49
50
+ const enum HoverWidgetType {
51
+ Content ,
52
+ Glyph ,
53
+ }
54
+
52
55
export class HoverController extends Disposable implements IEditorContribution {
53
56
54
57
public static readonly ID = 'editor.contrib.hover' ;
@@ -70,8 +73,6 @@ export class HoverController extends Disposable implements IEditorContribution {
70
73
constructor (
71
74
private readonly _editor : ICodeEditor ,
72
75
@IInstantiationService private readonly _instantiationService : IInstantiationService ,
73
- @IOpenerService private readonly _openerService : IOpenerService ,
74
- @ILanguageService private readonly _languageService : ILanguageService ,
75
76
@IKeybindingService private readonly _keybindingService : IKeybindingService
76
77
) {
77
78
super ( ) ;
@@ -276,23 +277,13 @@ export class HoverController extends Disposable implements IEditorContribution {
276
277
return ;
277
278
}
278
279
279
- const contentWidget = this . _getOrCreateContentWidget ( ) ;
280
-
281
- if ( contentWidget . showsOrWillShow ( mouseEvent ) ) {
282
- this . _glyphWidget ?. hide ( ) ;
280
+ const contentHoverShowsOrWillShow = this . _tryShowHoverWidget ( mouseEvent , HoverWidgetType . Content ) ;
281
+ if ( contentHoverShowsOrWillShow ) {
283
282
return ;
284
283
}
285
284
286
- if ( target . type === MouseTargetType . GUTTER_GLYPH_MARGIN && target . position && target . detail . glyphMarginLane ) {
287
- this . _contentWidget ?. hide ( ) ;
288
- const glyphWidget = this . _getOrCreateGlyphWidget ( ) ;
289
- glyphWidget . startShowingAt ( target . position . lineNumber , target . detail . glyphMarginLane ) ;
290
- return ;
291
- }
292
- if ( target . type === MouseTargetType . GUTTER_LINE_NUMBERS && target . position ) {
293
- this . _contentWidget ?. hide ( ) ;
294
- const glyphWidget = this . _getOrCreateGlyphWidget ( ) ;
295
- glyphWidget . startShowingAt ( target . position . lineNumber , 'lineNo' ) ;
285
+ const glyphWidgetShowsOrWillShow = this . _tryShowHoverWidget ( mouseEvent , HoverWidgetType . Glyph ) ;
286
+ if ( glyphWidgetShowsOrWillShow ) {
296
287
return ;
297
288
}
298
289
if ( _sticky ) {
@@ -301,6 +292,17 @@ export class HoverController extends Disposable implements IEditorContribution {
301
292
this . _hideWidgets ( ) ;
302
293
}
303
294
295
+ private _tryShowHoverWidget ( mouseEvent : IEditorMouseEvent , hoverWidgetType : HoverWidgetType ) : boolean {
296
+ const isContentWidget = hoverWidgetType === HoverWidgetType . Content ;
297
+ const currentWidget = isContentWidget ? this . _getOrCreateContentWidget ( ) : this . _getOrCreateGlyphWidget ( ) ;
298
+ const otherWidget = isContentWidget ? this . _getOrCreateGlyphWidget ( ) : this . _getOrCreateContentWidget ( ) ;
299
+ const showsOrWillShow = currentWidget . showsOrWillShow ( mouseEvent ) ;
300
+ if ( showsOrWillShow ) {
301
+ otherWidget . hide ( ) ;
302
+ }
303
+ return showsOrWillShow ;
304
+ }
305
+
304
306
private _onKeyDown ( e : IKeyboardEvent ) : void {
305
307
if ( ! this . _editor . hasModel ( ) ) {
306
308
return ;
@@ -357,7 +359,7 @@ export class HoverController extends Disposable implements IEditorContribution {
357
359
358
360
private _getOrCreateGlyphWidget ( ) : MarginHoverWidget {
359
361
if ( ! this . _glyphWidget ) {
360
- this . _glyphWidget = new MarginHoverWidget ( this . _editor , this . _languageService , this . _openerService ) ;
362
+ this . _glyphWidget = this . _instantiationService . createInstance ( MarginHoverWidget , this . _editor ) ;
361
363
}
362
364
return this . _glyphWidget ;
363
365
}
0 commit comments