make sure alternative goto-command is also a goto-command
This commit is contained in:
parent
5623111a12
commit
d90814dab4
1 changed files with 23 additions and 13 deletions
|
@ -9,7 +9,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
|
|||
import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { isWeb } from 'vs/base/common/platform';
|
||||
import { ICodeEditor, isCodeEditor, IActiveCodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction, IActionOptions, registerEditorAction, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { EditorAction, IActionOptions, registerInstantiatedEditorAction, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import * as corePosition from 'vs/editor/common/core/position';
|
||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
|
@ -53,6 +53,16 @@ export interface SymbolNavigationActionConfig {
|
|||
muteMessage: boolean;
|
||||
}
|
||||
|
||||
|
||||
const _goToActionIds = new Set<string>();
|
||||
|
||||
function registerGoToAction<T extends EditorAction>(ctor: { new(): T; }): T {
|
||||
const result = new ctor();
|
||||
registerInstantiatedEditorAction(result);
|
||||
_goToActionIds.add(result.id);
|
||||
return result;
|
||||
}
|
||||
|
||||
abstract class SymbolNavigationAction extends EditorAction {
|
||||
|
||||
private readonly _configuration: SymbolNavigationActionConfig;
|
||||
|
@ -87,7 +97,7 @@ abstract class SymbolNavigationAction extends EditorAction {
|
|||
let altAction: IEditorAction | null | undefined;
|
||||
if (references.referenceAt(model.uri, pos)) {
|
||||
const altActionId = this._getAlternativeCommand(editor);
|
||||
if (altActionId !== this.id) {
|
||||
if (altActionId !== this.id && _goToActionIds.has(altActionId)) {
|
||||
altAction = editor.getAction(altActionId);
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +238,7 @@ const goToDefinitionKb = isWeb && !isStandalone
|
|||
? KeyMod.CtrlCmd | KeyCode.F12
|
||||
: KeyCode.F12;
|
||||
|
||||
registerEditorAction(class GoToDefinitionAction extends DefinitionAction {
|
||||
registerGoToAction(class GoToDefinitionAction extends DefinitionAction {
|
||||
|
||||
static readonly id = 'editor.action.revealDefinition';
|
||||
|
||||
|
@ -264,7 +274,7 @@ registerEditorAction(class GoToDefinitionAction extends DefinitionAction {
|
|||
}
|
||||
});
|
||||
|
||||
registerEditorAction(class OpenDefinitionToSideAction extends DefinitionAction {
|
||||
registerGoToAction(class OpenDefinitionToSideAction extends DefinitionAction {
|
||||
|
||||
static readonly id = 'editor.action.revealDefinitionAside';
|
||||
|
||||
|
@ -290,7 +300,7 @@ registerEditorAction(class OpenDefinitionToSideAction extends DefinitionAction {
|
|||
}
|
||||
});
|
||||
|
||||
registerEditorAction(class PeekDefinitionAction extends DefinitionAction {
|
||||
registerGoToAction(class PeekDefinitionAction extends DefinitionAction {
|
||||
|
||||
static readonly id = 'editor.action.peekDefinition';
|
||||
|
||||
|
@ -349,7 +359,7 @@ class DeclarationAction extends SymbolNavigationAction {
|
|||
}
|
||||
}
|
||||
|
||||
registerEditorAction(class GoToDeclarationAction extends DeclarationAction {
|
||||
registerGoToAction(class GoToDeclarationAction extends DeclarationAction {
|
||||
|
||||
static readonly id = 'editor.action.revealDeclaration';
|
||||
|
||||
|
@ -386,7 +396,7 @@ registerEditorAction(class GoToDeclarationAction extends DeclarationAction {
|
|||
}
|
||||
});
|
||||
|
||||
registerEditorAction(class PeekDeclarationAction extends DeclarationAction {
|
||||
registerGoToAction(class PeekDeclarationAction extends DeclarationAction {
|
||||
constructor() {
|
||||
super({
|
||||
openToSide: false,
|
||||
|
@ -435,7 +445,7 @@ class TypeDefinitionAction extends SymbolNavigationAction {
|
|||
}
|
||||
}
|
||||
|
||||
registerEditorAction(class GoToTypeDefinitionAction extends TypeDefinitionAction {
|
||||
registerGoToAction(class GoToTypeDefinitionAction extends TypeDefinitionAction {
|
||||
|
||||
public static readonly ID = 'editor.action.goToTypeDefinition';
|
||||
|
||||
|
@ -470,7 +480,7 @@ registerEditorAction(class GoToTypeDefinitionAction extends TypeDefinitionAction
|
|||
}
|
||||
});
|
||||
|
||||
registerEditorAction(class PeekTypeDefinitionAction extends TypeDefinitionAction {
|
||||
registerGoToAction(class PeekTypeDefinitionAction extends TypeDefinitionAction {
|
||||
|
||||
public static readonly ID = 'editor.action.peekTypeDefinition';
|
||||
|
||||
|
@ -522,7 +532,7 @@ class ImplementationAction extends SymbolNavigationAction {
|
|||
}
|
||||
}
|
||||
|
||||
registerEditorAction(class GoToImplementationAction extends ImplementationAction {
|
||||
registerGoToAction(class GoToImplementationAction extends ImplementationAction {
|
||||
|
||||
public static readonly ID = 'editor.action.goToImplementation';
|
||||
|
||||
|
@ -557,7 +567,7 @@ registerEditorAction(class GoToImplementationAction extends ImplementationAction
|
|||
}
|
||||
});
|
||||
|
||||
registerEditorAction(class PeekImplementationAction extends ImplementationAction {
|
||||
registerGoToAction(class PeekImplementationAction extends ImplementationAction {
|
||||
|
||||
public static readonly ID = 'editor.action.peekImplementation';
|
||||
|
||||
|
@ -610,7 +620,7 @@ abstract class ReferencesAction extends SymbolNavigationAction {
|
|||
}
|
||||
}
|
||||
|
||||
registerEditorAction(class GoToReferencesAction extends ReferencesAction {
|
||||
registerGoToAction(class GoToReferencesAction extends ReferencesAction {
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
|
@ -649,7 +659,7 @@ registerEditorAction(class GoToReferencesAction extends ReferencesAction {
|
|||
}
|
||||
});
|
||||
|
||||
registerEditorAction(class PeekReferencesAction extends ReferencesAction {
|
||||
registerGoToAction(class PeekReferencesAction extends ReferencesAction {
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
|
|
Loading…
Reference in a new issue