"indentWithTab" works incorrectly when no language specified

CodeMirror provides a indentWithTab functionality to indent when pressing “Tab” key.
It works just fine and uses indentUnit.of(' '), (four spaces indent) when language is set for editor instance (for example JS, TS, YAML).

The problem is that when no language is specified for CodeMirror editor, it uses the default two spaces indent completely ignoring indentUnit.of(...) property.

Setting EditorState.tabSize.of(4) does not work too.

How do I fix this?

There is no association between the language and indentUnit. You can freely configure both independently. This sounds like whatever local code you’re using to get the language configuration may also be injecting an indent unit setting.

That’s not how the library works. If you can isolate this I can take a look, but I rather suspect you’re not setting up this configuration correctly.

1 Like