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')); 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 // 'basic' keymap only has basic keys by design, so we skip it
const extraKeysCommands = {}; const extraKeysCommands = {};
@ -64,7 +60,7 @@
// 'vim' and 'emacs' define their own autocomplete hotkeys // 'vim' and 'emacs' define their own autocomplete hotkeys
} }
if (!extraKeysCommands.blockComment) { if (!extraKeysCommands.blockComment) {
CodeMirror.keyMap.sublime['Shift-Ctrl-/'] = 'blockComment'; CodeMirror.keyMap.sublime['Shift-Ctrl-/'] = 'commentSelection';
} }
if (navigator.appVersion.includes('Windows')) { if (navigator.appVersion.includes('Windows')) {

View File

@ -17,10 +17,15 @@ onDOMscriptReady('/codemirror.js').then(() => {
toggleEditorFocus, toggleEditorFocus,
jumpToLine, jumpToLine,
nextEditor, prevEditor, nextEditor, prevEditor,
commentSelection,
}; };
// reroute handling to nearest editor when keypress resolves to one of these commands // reroute handling to nearest editor when keypress resolves to one of these commands
const REROUTED = new Set([ const REROUTED = new Set([
...Object.keys(COMMANDS), 'save',
'toggleStyle',
'jumpToLine',
'nextEditor', 'prevEditor',
'toggleEditorFocus',
'find', 'findNext', 'findPrev', 'replace', 'replaceAll', 'find', 'findNext', 'findPrev', 'replace', 'replaceAll',
'colorpicker', 'colorpicker',
]); ]);
@ -199,6 +204,10 @@ onDOMscriptReady('/codemirror.js').then(() => {
}, {value: cur.line + 1}); }, {value: cur.line + 1});
} }
function commentSelection(cm) {
cm.blockComment(cm.getCursor('from'), cm.getCursor('to'), {fullLines: false});
}
function toggleEditorFocus(cm) { function toggleEditorFocus(cm) {
if (!cm) return; if (!cm) return;
if (cm.hasFocus()) { if (cm.hasFocus()) {