|
6 | 6 | indentNodeProp, |
7 | 7 | foldNodeProp, |
8 | 8 | foldInside, |
9 | | - continuedIndent |
| 9 | + continuedIndent, |
| 10 | + flatIndent |
10 | 11 | } from "@codemirror/language"; |
11 | 12 | import { parseMixed } from "@lezer/common"; |
12 | 13 | import { styleTags, tags } from "@lezer/highlight"; |
@@ -43,10 +44,15 @@ export const csharpLanguage = LRLanguage.define({ |
43 | 44 | parser: parser.configure({ |
44 | 45 | props: [ |
45 | 46 | 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*{/ }) |
47 | 52 | }), |
48 | 53 | foldNodeProp.add({ |
49 | | - Delim: foldInside |
| 54 | + Delim: foldInside, |
| 55 | + BlockComment(tree) { return { from: tree.from + 2, to: tree.to - 2 } }, |
50 | 56 | }), |
51 | 57 | styleTags({ |
52 | 58 | "Keyword ContextualKeyword SimpleType": tags.keyword, |
@@ -103,7 +109,7 @@ export const csharpLanguage = LRLanguage.define({ |
103 | 109 | languageData: { |
104 | 110 | commentTokens: { line: "//", block: { open: "/*", close: "*/" } }, |
105 | 111 | closeBrackets: { brackets: ["(", "[", "{", '"', "'", '"""'] }, |
106 | | - indentOnInput: /^\s*((\)|\]|\})$|(else|else\s+if|catch|finally|case)\b|default:)/ |
| 112 | + indentOnInput: /^\s*([\)\]\}]$|(else|else\s+if|catch|finally)\b)/ |
107 | 113 | } |
108 | 114 | }); |
109 | 115 |
|
|
0 commit comments