Skip to content

Commit 484b967

Browse files
committed
code-editor: indent with two spaces instead of tabs
indentUnit was "\t", so getIndentUnit() resolved to tabSize (4) while every document in the app is pretty-printed with 2 spaces — JSON.stringify(x, null, 2) and YAML.dump({indent: 2}). continuedIndent() therefore asked for 4 columns and indentString() materialized them as a literal tab: pressing Enter inside a JSON object put the caret one level too deep and mixed tabs into space-indented content. Tab had the same problem through insertTab, which always inserts "\t" — invalid indentation in YAML. Use indentMore so Tab follows indentUnit, matching Enter and the existing Shift-Tab (indentLess) behaviour.
1 parent 6e75111 commit 484b967

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • packages/react-components/src/components/code-editor

packages/react-components/src/components/code-editor/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
history,
1414
historyKeymap,
1515
indentLess,
16-
insertTab,
16+
indentMore,
1717
} from "@codemirror/commands";
1818
import { json, jsonParseLinter } from "@codemirror/lang-json";
1919
import { SQLDialect, sql } from "@codemirror/lang-sql";
@@ -1509,7 +1509,7 @@ export function CodeEditor({
15091509
dropCursor(),
15101510
EditorState.allowMultipleSelections.of(true),
15111511
indentOnInput(),
1512-
indentUnit.of("\t"),
1512+
indentUnit.of(" "),
15131513
languageCompartment.current.of([]),
15141514
bracketMatching(),
15151515
closeBrackets(),
@@ -1540,7 +1540,7 @@ export function CodeEditor({
15401540
return moveCompletionSelection(true)(v);
15411541
}
15421542
if (v.state.readOnly) return false;
1543-
return insertTab(v);
1543+
return indentMore(v);
15441544
},
15451545
},
15461546
{

0 commit comments

Comments
 (0)