Skip to content

Commit

Permalink
Rebind Go to Definition to ctrl+f11
Browse files Browse the repository at this point in the history
Signed-off-by: svor <vsvydenk@redhat.com>
  • Loading branch information
svor authored and Valeriy Svydenko committed Oct 18, 2019
1 parent e997351 commit 162a48a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/monaco/src/browser/monaco-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export namespace MonacoCommands {
export const SELECTION_ADD_PREVIOUS_OCCURRENCE = 'editor.action.addSelectionToPreviousFindMatch';
export const SELECTION_SELECT_ALL_OCCURRENCES = 'editor.action.selectHighlights';

export const GO_TO_DEFINITION = 'editor.action.revealDefinition';

export const ACTIONS = new Map<string, MonacoCommand>();
ACTIONS.set(SELECTION_SELECT_ALL, { id: SELECTION_SELECT_ALL, label: 'Select All', delegate: 'editor.action.selectAll' });
export const EXCLUDE_ACTIONS = new Set([
Expand Down
13 changes: 9 additions & 4 deletions packages/monaco/src/browser/monaco-keybinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { EditorKeybindingContexts } from '@theia/editor/lib/browser';
import { MonacoCommands } from './monaco-command';
import { MonacoCommandRegistry } from './monaco-command-registry';
import { KEY_CODE_MAP } from './monaco-keycode-map';
import { isOSX } from '@theia/core';
import { isOSX, environment } from '@theia/core';

function monaco2BrowserKeyCode(keyCode: monaco.KeyCode): number {
for (let i = 0; i < KEY_CODE_MAP.length; i++) {
Expand All @@ -47,9 +47,14 @@ export class MonacoKeybindingContribution implements KeybindingContribution {
if (command) {
const raw = item.keybinding;
const when = item.when && item.when.serialize();
const keybinding = raw instanceof monaco.keybindings.SimpleKeybinding
? this.keyCode(raw).toString()
: this.keySequence(raw as monaco.keybindings.ChordKeybinding).join(' ');
let keybinding;
if (item.command === MonacoCommands.GO_TO_DEFINITION && !environment.electron.is()) {
keybinding = 'ctrlcmd+f11';
} else {
keybinding = raw instanceof monaco.keybindings.SimpleKeybinding
? this.keyCode(raw).toString()
: this.keySequence(raw as monaco.keybindings.ChordKeybinding).join(' ');
}
registry.registerKeybinding({ command, keybinding, when });
}
}
Expand Down

0 comments on commit 162a48a

Please sign in to comment.