From 32f415ddfe99713f44aa954526bbb2aaea7de595 Mon Sep 17 00:00:00 2001 From: Volodymyr Shatskyi Date: Fri, 15 Sep 2017 17:53:27 +0300 Subject: [PATCH] Add some emacs shortcuts. --- src/views/PromptComponent.tsx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/views/PromptComponent.tsx b/src/views/PromptComponent.tsx index 6c49c2169..d1edfc864 100644 --- a/src/views/PromptComponent.tsx +++ b/src/views/PromptComponent.tsx @@ -82,6 +82,30 @@ export class PromptComponent extends React.Component { () => this.setNextHistoryItem(), "!suggestWidgetVisible", ); + this.addShortcut( + monaco.KeyMod.WinCtrl | monaco.KeyCode.KEY_B, + "cursorLeft", + ); + this.addShortcut( + monaco.KeyMod.Alt | monaco.KeyCode.KEY_B, + "cursorWordStartLeft", + ); + this.addShortcut( + monaco.KeyMod.WinCtrl | monaco.KeyCode.KEY_F, + "cursorRight", + ); + this.addShortcut( + monaco.KeyMod.Alt | monaco.KeyCode.KEY_F, + "cursorWordEndRight", + ); + this.addShortcut( + monaco.KeyMod.WinCtrl | monaco.KeyCode.KEY_W, + "deleteWordLeft", + ); + this.addShortcut( + monaco.KeyMod.Alt | monaco.KeyCode.KEY_D, + "deleteWordRight", + ); this.focus(); } @@ -217,4 +241,12 @@ export class PromptComponent extends React.Component { private triggerSuggest() { this.editor.trigger(this.editor.getValue(), "editor.action.triggerSuggest", {}); } + + private addShortcut(keybinding: number, handlerId: string) { + this.editor.addCommand( + keybinding, + () => this.editor.trigger("", handlerId, {}), + "", + ); + } }