Skip to content

Commit 24c43ef

Browse files
authored
always use F12 for go to def, on web also register Cmd/Ctrl+F12 as fallback (microsoft#184585)
fixes microsoft#183953
1 parent cad3a1c commit 24c43ef

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/vs/editor/contrib/gotoSymbol/browser/goToCommands.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { isStandalone } from 'vs/base/browser/browser';
76
import { alert } from 'vs/base/browser/ui/aria/aria';
87
import { createCancelablePromise, raceCancellation } from 'vs/base/common/async';
98
import { CancellationToken } from 'vs/base/common/cancellation';
109
import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
11-
import { isWeb } from 'vs/base/common/platform';
1210
import { assertType } from 'vs/base/common/types';
1311
import { URI } from 'vs/base/common/uri';
1412
import { CodeEditorStateFlag, EditorStateCancellationTokenSource } from 'vs/editor/contrib/editorState/browser/editorState';
@@ -41,6 +39,7 @@ import { getDeclarationsAtPosition, getDefinitionsAtPosition, getImplementations
4139
import { IWordAtPosition } from 'vs/editor/common/core/wordHelper';
4240
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
4341
import { Iterable } from 'vs/base/common/iterator';
42+
import { IsWebContext } from 'vs/platform/contextkey/common/contextkeys';
4443

4544
MenuRegistry.appendMenuItem(MenuId.EditorContext, <ISubmenuItem>{
4645
submenu: MenuId.EditorContextPeek,
@@ -272,10 +271,6 @@ export class DefinitionAction extends SymbolNavigationAction {
272271
}
273272
}
274273

275-
const goToDefinitionKb = isWeb && !isStandalone()
276-
? KeyMod.CtrlCmd | KeyCode.F12
277-
: KeyCode.F12;
278-
279274
registerAction2(class GoToDefinitionAction extends DefinitionAction {
280275

281276
static readonly id = 'editor.action.revealDefinition';
@@ -295,11 +290,15 @@ registerAction2(class GoToDefinitionAction extends DefinitionAction {
295290
precondition: ContextKeyExpr.and(
296291
EditorContextKeys.hasDefinitionProvider,
297292
EditorContextKeys.isInWalkThroughSnippet.toNegated()),
298-
keybinding: {
293+
keybinding: [{
299294
when: EditorContextKeys.editorTextFocus,
300-
primary: goToDefinitionKb,
295+
primary: KeyCode.F12,
301296
weight: KeybindingWeight.EditorContrib
302-
},
297+
}, {
298+
when: ContextKeyExpr.and(EditorContextKeys.editorTextFocus, IsWebContext),
299+
primary: KeyMod.CtrlCmd | KeyCode.F12,
300+
weight: KeybindingWeight.EditorContrib
301+
}],
303302
menu: [{
304303
id: MenuId.EditorContext,
305304
group: 'navigation',
@@ -333,11 +332,15 @@ registerAction2(class OpenDefinitionToSideAction extends DefinitionAction {
333332
precondition: ContextKeyExpr.and(
334333
EditorContextKeys.hasDefinitionProvider,
335334
EditorContextKeys.isInWalkThroughSnippet.toNegated()),
336-
keybinding: {
335+
keybinding: [{
337336
when: EditorContextKeys.editorTextFocus,
338-
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, goToDefinitionKb),
337+
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyCode.F12),
339338
weight: KeybindingWeight.EditorContrib
340-
}
339+
}, {
340+
when: ContextKeyExpr.and(EditorContextKeys.editorTextFocus, IsWebContext),
341+
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.F12),
342+
weight: KeybindingWeight.EditorContrib
343+
}]
341344
});
342345
CommandsRegistry.registerCommandAlias('editor.action.openDeclarationToTheSide', OpenDefinitionToSideAction.id);
343346
}

0 commit comments

Comments
 (0)