diff --git a/edit/codemirror-default.js b/edit/codemirror-default.js index 859a7625..1157e699 100644 --- a/edit/codemirror-default.js +++ b/edit/codemirror-default.js @@ -38,10 +38,6 @@ Object.assign(CodeMirror.defaults, defaults, prefs.get('editor.options')); - CodeMirror.commands.blockComment = cm => { - cm.blockComment(cm.getCursor('from'), cm.getCursor('to'), {fullLines: false}); - }; - // 'basic' keymap only has basic keys by design, so we skip it const extraKeysCommands = {}; @@ -64,7 +60,7 @@ // 'vim' and 'emacs' define their own autocomplete hotkeys } if (!extraKeysCommands.blockComment) { - CodeMirror.keyMap.sublime['Shift-Ctrl-/'] = 'blockComment'; + CodeMirror.keyMap.sublime['Shift-Ctrl-/'] = 'commentSelection'; } if (navigator.appVersion.includes('Windows')) { diff --git a/edit/codemirror-editing-hooks.js b/edit/codemirror-editing-hooks.js index b2fe7ab3..89159aa3 100644 --- a/edit/codemirror-editing-hooks.js +++ b/edit/codemirror-editing-hooks.js @@ -17,10 +17,15 @@ onDOMscriptReady('/codemirror.js').then(() => { toggleEditorFocus, jumpToLine, nextEditor, prevEditor, + commentSelection, }; // reroute handling to nearest editor when keypress resolves to one of these commands const REROUTED = new Set([ - ...Object.keys(COMMANDS), + 'save', + 'toggleStyle', + 'jumpToLine', + 'nextEditor', 'prevEditor', + 'toggleEditorFocus', 'find', 'findNext', 'findPrev', 'replace', 'replaceAll', 'colorpicker', ]); @@ -199,6 +204,10 @@ onDOMscriptReady('/codemirror.js').then(() => { }, {value: cur.line + 1}); } + function commentSelection(cm) { + cm.blockComment(cm.getCursor('from'), cm.getCursor('to'), {fullLines: false}); + } + function toggleEditorFocus(cm) { if (!cm) return; if (cm.hasFocus()) {