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
This commit is contained in:
Johannes Rieken
2022-06-24 16:50:18 +02:00
committed by GitHub
parent 70ea7331ac
commit fefdf2e462
@@ -85,6 +85,8 @@ export class SymbolNavigationAnchor {
export abstract class SymbolNavigationAction extends EditorAction {
private static _activeAlternativeCommands = new Set<string>();
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