Skip to content

Commit

Permalink
fix(code-editor): indent with spaces
Browse files Browse the repository at this point in the history
Backport of feature from the Lime Angular code editor.
When a user hits tab it will indent with spaces instead of tabs.
  • Loading branch information
anderssonjohan authored and mjlime committed Sep 9, 2022
1 parent 6880134 commit 323fb35
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/code-editor/code-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 323fb35

Please sign in to comment.