insert spaces on <Tab> when editor.indentWithTabs is false

This commit is contained in:
tophf 2018-05-01 23:05:13 +03:00
parent 923f55d532
commit 05dbcff7c3

View File

@ -19,6 +19,9 @@ onDOMscriptReady('/codemirror.js').then(() => {
nextEditor, prevEditor,
commentSelection,
};
const ORIGINAL_COMMANDS = {
insertTab: CodeMirror.commands.insertTab,
};
// reroute handling to nearest editor when keypress resolves to one of these commands
const REROUTED = new Set([
'save',
@ -244,6 +247,12 @@ onDOMscriptReady('/codemirror.js').then(() => {
CodeMirror.setOption('indentUnit', value);
break;
case 'indentWithTabs':
CodeMirror.commands.insertTab = value ?
ORIGINAL_COMMANDS.insertTab :
CodeMirror.commands.insertSoftTab;
break;
case 'theme': {
const themeLink = $('#cm-theme');
// use non-localized 'default' internally