Skip to content

Commit 942f22a

Browse files
committed
Fix indentation of blocks
FIX: Add the appropriate indentation metadata for blocks. Closes codemirror/dev#866
1 parent cb866d9 commit 942f22a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/cpp.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {parser} from "@lezer/cpp"
2-
import {flatIndent, continuedIndent, indentNodeProp, foldNodeProp, foldInside,
2+
import {flatIndent, continuedIndent, delimitedIndent, indentNodeProp,
3+
foldNodeProp, foldInside,
34
LRLanguage, LanguageSupport} from "@codemirror/language"
45

56
/// A language provider based on the [Lezer C++
@@ -14,6 +15,7 @@ export const cppLanguage = LRLanguage.define({
1415
LabeledStatement: flatIndent,
1516
CaseStatement: context => context.baseIndent + context.unit,
1617
BlockComment: () => -1,
18+
CompoundStatement: delimitedIndent({closing: "}"}),
1719
Statement: continuedIndent({except: /^{/})
1820
}),
1921
foldNodeProp.add({

0 commit comments

Comments
 (0)