I'm gathering examples of PowerShell syntax that VS Code highlights poorly. If you have one, what code triggers it and which theme are you using?
I'm also looking at support for function names that don't follow the Verb-Noun convention.
I'm gathering examples of PowerShell syntax that VS Code highlights poorly. If you have one, what code triggers it and which theme are you using?
I'm also looking at support for function names that don't follow the Verb-Noun convention.
Non-Verb-Noun function names are worth testing alongside conventional names. A function named DoSomething shouldn't be overlooked just because it lacks a hyphen. It would also be useful to check names such as Command123 against actual PowerShell keywords, so a broader command-name rule doesn't swallow those.
For anyone wondering how to spot a highlighting problem, open a PowerShell file and run Developer: Inspect Editor Tokens and Scopes from the command palette. Click through the code and look at the TextMate scopes assigned to each token.
That can help distinguish a grammar issue from a theme issue. A token may have a sensible scope but still look odd because of how the theme colors it. Include a small code sample, the theme name, and what you expected to see in a report.
I'd add regression tests for the null operators ??, ??=, ?., and ?[], as well as question marks inside variable names. Those are easy examples to check separately, but also worth testing in surrounding expressions where token boundaries can get tricky.
Small fixes are useful, but please map out how the grammar rules fit together. A permissive rule for command names can conflict with keyword matching, and patching each collision afterward could get messy.
Tests using VS Code's tokenizer would help catch regressions as the rules change. They don't replace a design, but they make it easier to see what a change broke.
A parser-based approach such as Tree-sitter or language-server highlighting might be worth exploring longer term. That is a bigger project than fixing the current TextMate grammar, though, so there's still value in improving what people have now.
Answers are reviewed before publication.
Related Discussions