|
@@ -883,14 +883,15 @@ export class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
this._changeGuard = true;
|
|
|
const doc = this.doc;
|
|
|
switch (args.type) {
|
|
|
- case 'insert':
|
|
|
+ case 'insert': {
|
|
|
const pos = doc.posFromIndex(args.start);
|
|
|
// Replace the range, including a '+input' orign,
|
|
|
// which indicates that CodeMirror may merge changes
|
|
|
// for undo/redo purposes.
|
|
|
doc.replaceRange(args.value, pos, pos, '+input');
|
|
|
break;
|
|
|
- case 'remove':
|
|
|
+ }
|
|
|
+ case 'remove': {
|
|
|
const from = doc.posFromIndex(args.start);
|
|
|
const to = doc.posFromIndex(args.end);
|
|
|
// Replace the range, including a '+input' orign,
|
|
@@ -898,6 +899,7 @@ export class CodeMirrorEditor implements CodeEditor.IEditor {
|
|
|
// for undo/redo purposes.
|
|
|
doc.replaceRange('', from, to, '+input');
|
|
|
break;
|
|
|
+ }
|
|
|
case 'set':
|
|
|
doc.setValue(args.value);
|
|
|
break;
|
|
@@ -1449,7 +1451,7 @@ namespace Private {
|
|
|
): void {
|
|
|
const el = editor.getWrapperElement();
|
|
|
switch (option) {
|
|
|
- case 'lineWrap':
|
|
|
+ case 'lineWrap': {
|
|
|
const lineWrapping = value === 'off' ? false : true;
|
|
|
const lines = el.querySelector('.CodeMirror-lines') as HTMLDivElement;
|
|
|
const maxWidth =
|
|
@@ -1460,7 +1462,8 @@ namespace Private {
|
|
|
lines.style.setProperty('width', width);
|
|
|
editor.setOption('lineWrapping', lineWrapping);
|
|
|
break;
|
|
|
- case 'wordWrapColumn':
|
|
|
+ }
|
|
|
+ case 'wordWrapColumn': {
|
|
|
const { lineWrap } = config;
|
|
|
if (lineWrap === 'wordWrapColumn' || lineWrap === 'bounded') {
|
|
|
const lines = el.querySelector('.CodeMirror-lines') as HTMLDivElement;
|
|
@@ -1468,6 +1471,7 @@ namespace Private {
|
|
|
lines.style[prop] = `${value}ch`;
|
|
|
}
|
|
|
break;
|
|
|
+ }
|
|
|
case 'tabSize':
|
|
|
editor.setOption('indentUnit', value);
|
|
|
break;
|
|
@@ -1477,7 +1481,7 @@ namespace Private {
|
|
|
case 'autoClosingBrackets':
|
|
|
editor.setOption('autoCloseBrackets', value);
|
|
|
break;
|
|
|
- case 'rulers':
|
|
|
+ case 'rulers': {
|
|
|
const rulers = value as Array<number>;
|
|
|
editor.setOption(
|
|
|
'rulers',
|
|
@@ -1489,6 +1493,7 @@ namespace Private {
|
|
|
})
|
|
|
);
|
|
|
break;
|
|
|
+ }
|
|
|
case 'readOnly':
|
|
|
el.classList.toggle(READ_ONLY_CLASS, value);
|
|
|
editor.setOption(option, value);
|