Skip to content

Commit 8450414

Browse files
committed
further enhancements
1 parent ed744c1 commit 8450414

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

web_src/js/features/codeeditor.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ type MonacoOpts = IEditorOptions & IGlobalEditorOptions & ITextModelUpdateOption
1212

1313
type EditorConfig = {
1414
indent_style?: 'tab' | 'space',
15-
indent_size?: number,
16-
tab_width?: number,
15+
indent_size?: string | number, // backend emits this as string
16+
tab_width?: string | number, // backend emits this as string
1717
end_of_line?: 'lf' | 'cr' | 'crlf',
1818
charset?: 'latin1' | 'utf-8' | 'utf-8-bom' | 'utf-16be' | 'utf-16le',
1919
trim_trailing_whitespace?: boolean,
@@ -215,9 +215,17 @@ function getEditorConfigOptions(ec: EditorConfig | null): MonacoOpts {
215215

216216
const opts: MonacoOpts = {};
217217
opts.detectIndentation = !('indent_style' in ec) || !('indent_size' in ec);
218-
if ('indent_size' in ec) opts.indentSize = Number(ec.indent_size);
219-
if ('tab_width' in ec) opts.tabSize = Number(ec.tab_width) || (opts.indentSize as number);
220-
if ('max_line_length' in ec) opts.rulers = [Number(ec.max_line_length)];
218+
219+
if ('indent_size' in ec) {
220+
opts.indentSize = Number(ec.indent_size);
221+
}
222+
if ('tab_width' in ec) {
223+
opts.tabSize = Number(ec.tab_width) || Number(ec.indent_size);
224+
}
225+
if ('max_line_length' in ec) {
226+
opts.rulers = [Number(ec.max_line_length)];
227+
}
228+
221229
opts.trimAutoWhitespace = ec.trim_trailing_whitespace === true;
222230
opts.insertSpaces = ec.indent_style === 'space';
223231
opts.useTabStops = ec.indent_style === 'tab';

0 commit comments

Comments
 (0)