Skip to content

Commit f8de980

Browse files
committed
feat: add ObjectScript enter rules for semicolon continuation
1 parent cb593bd commit f8de980

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/languageConfiguration.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ import * as vscode from "vscode";
22

33
export function getLanguageConfiguration(lang: string): vscode.LanguageConfiguration {
44
const conf = vscode.workspace.getConfiguration("objectscript");
5+
const onEnterRules: vscode.OnEnterRule[] = [];
6+
7+
if (lang === "objectscript-class") {
8+
onEnterRules.push({
9+
beforeText: /^\/\/\//,
10+
action: { indentAction: vscode.IndentAction.None, appendText: "/// " },
11+
});
12+
}
13+
14+
if (["objectscript", "objectscript-int"].includes(lang)) {
15+
onEnterRules.push({
16+
beforeText: /^\s*;/,
17+
action: { indentAction: vscode.IndentAction.None, appendText: ";" },
18+
});
19+
}
520
return {
621
wordPattern:
722
/((?<=(class|extends|as|of) )(%?\b[a-z0-9]+(\.[a-z0-9]+)*\b))|(\^[a-z0-9]+(\.[a-z0-9]+)*)|((\${1,3}|[irm]?%|\^|#)?[a-z0-9]+)/i,
@@ -40,14 +55,6 @@ export function getLanguageConfiguration(lang: string): vscode.LanguageConfigura
4055
notIn: [vscode.SyntaxTokenType.Comment, vscode.SyntaxTokenType.String, vscode.SyntaxTokenType.RegEx],
4156
},
4257
],
43-
onEnterRules:
44-
lang == "objectscript-class"
45-
? [
46-
{
47-
beforeText: /^\/\/\//,
48-
action: { indentAction: vscode.IndentAction.None, appendText: "/// " },
49-
},
50-
]
51-
: undefined,
58+
onEnterRules: onEnterRules.length ? onEnterRules : undefined,
5259
};
5360
}

0 commit comments

Comments
 (0)