move commentSelection command to other editing commands

This commit is contained in:
tophf 2018-03-03 23:31:21 +03:00
parent 6e8ff5b9ef
commit 2c86f2f4b9
2 changed files with 11 additions and 6 deletions

View File

@ -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')) {

View File

@ -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()) {