From fefdf2e46262e9521db92d7bc773bf80d6ea6707 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 24 Jun 2022 16:50:18 +0200 Subject: [PATCH] keep a stack of active alternative go-to command invocations and prevent endless recursion with that. (this needed a static cached because I cannot pass a "don't recurse" flag to the underlying editor action) (#153123) fixes https://github.com/microsoft/vscode/issues/153035 --- src/vs/editor/contrib/gotoSymbol/browser/goToCommands.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/contrib/gotoSymbol/browser/goToCommands.ts b/src/vs/editor/contrib/gotoSymbol/browser/goToCommands.ts index cb1b242d7a3..03b9ee293a5 100644 --- a/src/vs/editor/contrib/gotoSymbol/browser/goToCommands.ts +++ b/src/vs/editor/contrib/gotoSymbol/browser/goToCommands.ts @@ -85,6 +85,8 @@ export class SymbolNavigationAnchor { export abstract class SymbolNavigationAction extends EditorAction { + private static _activeAlternativeCommands = new Set(); + readonly configuration: SymbolNavigationActionConfig; constructor(configuration: SymbolNavigationActionConfig, opts: IActionOptions) { @@ -119,7 +121,7 @@ export abstract class SymbolNavigationAction extends EditorAction { let altAction: IEditorAction | null | undefined; if (references.referenceAt(model.uri, position)) { const altActionId = this._getAlternativeCommand(editor); - if (altActionId !== this.id && _goToActionIds.has(altActionId)) { + if (!SymbolNavigationAction._activeAlternativeCommands.has(altActionId) && _goToActionIds.has(altActionId)) { altAction = editor.getAction(altActionId); } } @@ -134,7 +136,10 @@ export abstract class SymbolNavigationAction extends EditorAction { } } else if (referenceCount === 1 && altAction) { // already at the only result, run alternative - altAction.run(); + SymbolNavigationAction._activeAlternativeCommands.add(this.id); + altAction.run().finally(() => { + SymbolNavigationAction._activeAlternativeCommands.delete(this.id); + }); } else { // normal results handling