Skip to content

Commit 35eb869

Browse files
author
aiday-mar
committed
Revealing the line before invoking the functions when there are several possible definitions
1 parent 7574795 commit 35eb869

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/vs/editor/contrib/stickyScroll/browser/stickyScrollWidget.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class StickyScrollWidget extends Disposable implements IOverlayWidget {
4646
private _hoverOnLine: number;
4747
private _hoverOnColumn: number;
4848
private _stickyRangeProjectedOnEditor: IRange | null;
49+
private _candidateDefinitionsLength: number;
4950

5051
constructor(
5152
private readonly _editor: ICodeEditor,
@@ -62,6 +63,7 @@ export class StickyScrollWidget extends Disposable implements IOverlayWidget {
6263
this._hoverOnLine = -1;
6364
this._hoverOnColumn = -1;
6465
this._stickyRangeProjectedOnEditor = null;
66+
this._candidateDefinitionsLength = -1;
6567
this._lineHeight = this._editor.getOption(EditorOption.lineHeight);
6668
this._register(this._editor.onDidChangeConfiguration(e => {
6769
if (e.hasChanged(EditorOption.lineHeight)) {
@@ -113,6 +115,7 @@ export class StickyScrollWidget extends Disposable implements IOverlayWidget {
113115
return;
114116
}
115117
if (candidateDefinitions.length !== 0) {
118+
this._candidateDefinitionsLength = candidateDefinitions.length;
116119
const childHTML: HTMLElement = targetMouseEvent.element;
117120
if (currentHTMLChild !== childHTML) {
118121
sessionStore.clear();
@@ -143,11 +146,17 @@ export class StickyScrollWidget extends Disposable implements IOverlayWidget {
143146
if (this._hoverOnLine !== -1) {
144147
if (e.hasTriggerModifier) {
145148
// 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+
}
147155
} else {
148156
// Normal click
149157
this._editor.revealPosition({ lineNumber: this._hoverOnLine, column: 1 });
150158
}
159+
this._hoverOnLine = -1;
151160
}
152161

153162
}));
@@ -274,6 +283,12 @@ export class StickyScrollWidget extends Disposable implements IOverlayWidget {
274283
this._hoverOnColumn = this._editor.getModel().getLineContent(line).indexOf(text) + 1 || -1;
275284
}
276285
}));
286+
this._disposableStore.add(dom.addDisposableListener(child, 'mouseout', () => {
287+
if (this._editor.hasModel()) {
288+
this._hoverOnLine = -1;
289+
this._hoverOnColumn = -1;
290+
}
291+
}));
277292

278293
return child;
279294
}

0 commit comments

Comments
 (0)