Skip to content

Commit 4cef4ea

Browse files
authored
lsh: fix up PowerShell a bit (#784)
Make keywords case-insensitive, and add class/enum/cmdletbinding/static to other keywords. Disallow keywords from being followed by anything.
1 parent 05452ab commit 4cef4ea

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

crates/lsh/definitions/powershell.lsh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,18 @@ pub fn powershell() {
3535
else if /"/ { yield string; break; }
3636
await input;
3737
}
38-
} else if /function|param/ {
39-
yield keyword.other;
40-
} else if /elseif|else|if|for|switch|default|throw|try|catch|finally/ {
41-
yield keyword.control;
38+
} else if /(?i:function|param|class|enum|cmdletbinding|static)/ {
39+
if /\w+/ {
40+
yield other;
41+
} else {
42+
yield keyword.other;
43+
}
44+
} else if /(?i:elseif|else|if|for(each)?|switch|default|throw|try|catch|finally|return)/ {
45+
if /\w+/ {
46+
yield other;
47+
} else {
48+
yield keyword.control;
49+
}
4250
} else if /-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/ {
4351
if /[\w\-]+/ {
4452
yield method;

0 commit comments

Comments
 (0)