Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always use F12 for go to def, on web also register Cmd/Ctrl+F12 as fallback #184585

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 15 additions & 12 deletions src/vs/editor/contrib/gotoSymbol/browser/goToCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { isStandalone } from 'vs/base/browser/browser';
import { alert } from 'vs/base/browser/ui/aria/aria';
import { createCancelablePromise, raceCancellation } from 'vs/base/common/async';
import { CancellationToken } from 'vs/base/common/cancellation';
import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { isWeb } from 'vs/base/common/platform';
import { assertType } from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
import { CodeEditorStateFlag, EditorStateCancellationTokenSource } from 'vs/editor/contrib/editorState/browser/editorState';
Expand Down Expand Up @@ -41,6 +39,7 @@ import { getDeclarationsAtPosition, getDefinitionsAtPosition, getImplementations
import { IWordAtPosition } from 'vs/editor/common/core/wordHelper';
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
import { Iterable } from 'vs/base/common/iterator';
import { IsWebContext } from 'vs/platform/contextkey/common/contextkeys';

MenuRegistry.appendMenuItem(MenuId.EditorContext, <ISubmenuItem>{
submenu: MenuId.EditorContextPeek,
Expand Down Expand Up @@ -272,10 +271,6 @@ export class DefinitionAction extends SymbolNavigationAction {
}
}

const goToDefinitionKb = isWeb && !isStandalone()
? KeyMod.CtrlCmd | KeyCode.F12
: KeyCode.F12;

registerAction2(class GoToDefinitionAction extends DefinitionAction {

static readonly id = 'editor.action.revealDefinition';
Expand All @@ -295,11 +290,15 @@ registerAction2(class GoToDefinitionAction extends DefinitionAction {
precondition: ContextKeyExpr.and(
EditorContextKeys.hasDefinitionProvider,
EditorContextKeys.isInWalkThroughSnippet.toNegated()),
keybinding: {
keybinding: [{
when: EditorContextKeys.editorTextFocus,
primary: goToDefinitionKb,
primary: KeyCode.F12,
weight: KeybindingWeight.EditorContrib
},
}, {
when: ContextKeyExpr.and(EditorContextKeys.editorTextFocus, IsWebContext),
primary: KeyMod.CtrlCmd | KeyCode.F12,
weight: KeybindingWeight.EditorContrib
}],
menu: [{
id: MenuId.EditorContext,
group: 'navigation',
Expand Down Expand Up @@ -333,11 +332,15 @@ registerAction2(class OpenDefinitionToSideAction extends DefinitionAction {
precondition: ContextKeyExpr.and(
EditorContextKeys.hasDefinitionProvider,
EditorContextKeys.isInWalkThroughSnippet.toNegated()),
keybinding: {
keybinding: [{
when: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, goToDefinitionKb),
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyCode.F12),
weight: KeybindingWeight.EditorContrib
}
}, {
when: ContextKeyExpr.and(EditorContextKeys.editorTextFocus, IsWebContext),
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.F12),
weight: KeybindingWeight.EditorContrib
}]
});
CommandsRegistry.registerCommandAlias('editor.action.openDeclarationToTheSide', OpenDefinitionToSideAction.id);
}
Expand Down