From a03b1546bf7e9e4bcdcbcd49fb493b44851cf8cf Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 25 Apr 2018 13:52:13 -0400 Subject: [PATCH] Fix autocomplete hotkey in settings (Fixes #872) --- packages/insomnia-app/app/common/hotkeys.js | 4 +++- .../app/ui/components/codemirror/code-editor.js | 4 ++-- packages/insomnia-app/app/ui/components/hotkey.js | 10 +++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/insomnia-app/app/common/hotkeys.js b/packages/insomnia-app/app/common/hotkeys.js index 754b88e6df..4ff9aa6cca 100644 --- a/packages/insomnia-app/app/common/hotkeys.js +++ b/packages/insomnia-app/app/common/hotkeys.js @@ -8,7 +8,8 @@ export type Hotkey = { meta: boolean, alt: boolean, shift: boolean, - keycode: number | Array + keycode: number | Array, + metaIsCtrl?: boolean, }; export const SHOW_WORKSPACE_SETTINGS: Hotkey = { @@ -70,6 +71,7 @@ export const RELOAD_PLUGINS: Hotkey = { export const SHOW_AUTOCOMPLETE: Hotkey = { description: 'Show Autocomplete', meta: true, + metaIsCtrl: true, alt: false, shift: false, keycode: keycodes.space diff --git a/packages/insomnia-app/app/ui/components/codemirror/code-editor.js b/packages/insomnia-app/app/ui/components/codemirror/code-editor.js index 7f139275cd..025bcaeb26 100644 --- a/packages/insomnia-app/app/ui/components/codemirror/code-editor.js +++ b/packages/insomnia-app/app/ui/components/codemirror/code-editor.js @@ -49,7 +49,7 @@ const BASE_CODEMIRROR_OPTIONS = { showCursorWhenSelecting: false, cursorScrollMargin: 12, // NOTE: This is px keyMap: 'default', - extraKeys: { + extraKeys: CodeMirror.normalizeKeyMap({ 'Ctrl-Q': function (cm) { cm.foldCode(cm.getCursor()); }, @@ -61,7 +61,7 @@ const BASE_CODEMIRROR_OPTIONS = { // Change default find command from "find" to "findPersistent" so the // search box stays open after pressing Enter [isMac() ? 'Cmd-F' : 'Ctrl-F']: 'findPersistent' - } + }) }; @autobind diff --git a/packages/insomnia-app/app/ui/components/hotkey.js b/packages/insomnia-app/app/ui/components/hotkey.js index 9867353c3b..729c8fd8b4 100644 --- a/packages/insomnia-app/app/ui/components/hotkey.js +++ b/packages/insomnia-app/app/ui/components/hotkey.js @@ -15,14 +15,18 @@ type Props = { class Hotkey extends React.PureComponent { render () { const {hotkey, className} = this.props; - const {alt, shift, meta} = hotkey; - const chars = [ ]; + const {alt, shift, meta, metaIsCtrl} = hotkey; + const chars = []; alt && chars.push(ALT_SYM); shift && chars.push(SHIFT_SYM); if (meta) { - chars.push(isMac() ? MOD_SYM : CTRL_SYM); + if (metaIsCtrl) { + chars.push(CTRL_SYM); + } else { + chars.push(isMac() ? MOD_SYM : CTRL_SYM); + } } chars.push(hotkeys.getChar(hotkey));