@@ -46,6 +46,7 @@ export class StickyScrollWidget extends Disposable implements IOverlayWidget {
46
46
private _hoverOnLine : number ;
47
47
private _hoverOnColumn : number ;
48
48
private _stickyRangeProjectedOnEditor : IRange | null ;
49
+ private _candidateDefinitionsLength : number ;
49
50
50
51
constructor (
51
52
private readonly _editor : ICodeEditor ,
@@ -62,6 +63,7 @@ export class StickyScrollWidget extends Disposable implements IOverlayWidget {
62
63
this . _hoverOnLine = - 1 ;
63
64
this . _hoverOnColumn = - 1 ;
64
65
this . _stickyRangeProjectedOnEditor = null ;
66
+ this . _candidateDefinitionsLength = - 1 ;
65
67
this . _lineHeight = this . _editor . getOption ( EditorOption . lineHeight ) ;
66
68
this . _register ( this . _editor . onDidChangeConfiguration ( e => {
67
69
if ( e . hasChanged ( EditorOption . lineHeight ) ) {
@@ -113,6 +115,7 @@ export class StickyScrollWidget extends Disposable implements IOverlayWidget {
113
115
return ;
114
116
}
115
117
if ( candidateDefinitions . length !== 0 ) {
118
+ this . _candidateDefinitionsLength = candidateDefinitions . length ;
116
119
const childHTML : HTMLElement = targetMouseEvent . element ;
117
120
if ( currentHTMLChild !== childHTML ) {
118
121
sessionStore . clear ( ) ;
@@ -143,11 +146,17 @@ export class StickyScrollWidget extends Disposable implements IOverlayWidget {
143
146
if ( this . _hoverOnLine !== - 1 ) {
144
147
if ( e . hasTriggerModifier ) {
145
148
// Control click
146
- this . _instaService . invokeFunction ( goToDefinitionWithLocation , e , this . _editor as IActiveCodeEditor , { uri : this . _editor . getModel ( ) ! . uri , range : this . _stickyRangeProjectedOnEditor } as Location ) ;
149
+ if ( this . _candidateDefinitionsLength === 1 ) {
150
+ this . _instaService . invokeFunction ( goToDefinitionWithLocation , e , this . _editor as IActiveCodeEditor , { uri : this . _editor . getModel ( ) ! . uri , range : this . _stickyRangeProjectedOnEditor } as Location ) ;
151
+ } else {
152
+ this . _editor . revealPosition ( { lineNumber : this . _hoverOnLine , column : 1 } ) ;
153
+ this . _instaService . invokeFunction ( goToDefinitionWithLocation , e , this . _editor as IActiveCodeEditor , { uri : this . _editor . getModel ( ) ! . uri , range : this . _stickyRangeProjectedOnEditor } as Location ) ;
154
+ }
147
155
} else {
148
156
// Normal click
149
157
this . _editor . revealPosition ( { lineNumber : this . _hoverOnLine , column : 1 } ) ;
150
158
}
159
+ this . _hoverOnLine = - 1 ;
151
160
}
152
161
153
162
} ) ) ;
@@ -274,6 +283,12 @@ export class StickyScrollWidget extends Disposable implements IOverlayWidget {
274
283
this . _hoverOnColumn = this . _editor . getModel ( ) . getLineContent ( line ) . indexOf ( text ) + 1 || - 1 ;
275
284
}
276
285
} ) ) ;
286
+ this . _disposableStore . add ( dom . addDisposableListener ( child , 'mouseout' , ( ) => {
287
+ if ( this . _editor . hasModel ( ) ) {
288
+ this . _hoverOnLine = - 1 ;
289
+ this . _hoverOnColumn = - 1 ;
290
+ }
291
+ } ) ) ;
277
292
278
293
return child ;
279
294
}
0 commit comments