Skip to content

Commit b911ba2

Browse files
committed
Add indentNodeProp item
1 parent 802aba9 commit b911ba2

2 files changed

Lines changed: 240 additions & 234 deletions

File tree

src/csharp.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
indentNodeProp,
77
foldNodeProp,
88
foldInside,
9-
continuedIndent
9+
continuedIndent,
10+
flatIndent
1011
} from "@codemirror/language";
1112
import { parseMixed } from "@lezer/common";
1213
import { styleTags, tags } from "@lezer/highlight";
@@ -43,10 +44,15 @@ export const csharpLanguage = LRLanguage.define({
4344
parser: parser.configure({
4445
props: [
4546
indentNodeProp.add({
46-
Delim: continuedIndent({ except: /^\s*(?:case\b|default:)/ })
47+
Delim: continuedIndent({ except: /^\s*[\)\]\}]/ }),
48+
IfStmt: continuedIndent({ except: /^\s*({|else\b)/ }),
49+
TryStmt: continuedIndent({ except: /^\s*({|catch\b|finally\b)/ }),
50+
LabeledStmt: flatIndent,
51+
"Expression Declaration Statement": continuedIndent({ except: /^\s*{/ })
4752
}),
4853
foldNodeProp.add({
49-
Delim: foldInside
54+
Delim: foldInside,
55+
BlockComment(tree) { return { from: tree.from + 2, to: tree.to - 2 } },
5056
}),
5157
styleTags({
5258
"Keyword ContextualKeyword SimpleType": tags.keyword,
@@ -103,7 +109,7 @@ export const csharpLanguage = LRLanguage.define({
103109
languageData: {
104110
commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
105111
closeBrackets: { brackets: ["(", "[", "{", '"', "'", '"""'] },
106-
indentOnInput: /^\s*((\)|\]|\})$|(else|else\s+if|catch|finally|case)\b|default:)/
112+
indentOnInput: /^\s*([\)\]\}]$|(else|else\s+if|catch|finally)\b)/
107113
}
108114
});
109115

0 commit comments

Comments
 (0)