diff --git a/src/components/code-editor/code-editor.tsx b/src/components/code-editor/code-editor.tsx index 6f5153e19c..27b3be4622 100644 --- a/src/components/code-editor/code-editor.tsx +++ b/src/components/code-editor/code-editor.tsx @@ -169,6 +169,17 @@ export class CodeEditor { editor.on('change', this.handleChange); + // Replace tab with spaces and use the actual indent setting for + // the space count + editor.setOption('extraKeys', { + Tab: (codeMirror) => { + const spaces = Array( + codeMirror.getOption('indentUnit') + 1 + ).join(' '); + codeMirror.replaceSelection(spaces); + }, + }); + return editor; }