What PowerShell syntax highlighting problems should be fixed in VS Code?

November 18, 2026 5 answers
Asked by 7r!claspmaraca_582

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.

Answers

9t~ferrulecaddy_348

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.

Reply to this answer
Nola

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.

Reply to this answer
_j48+zavmelo.5

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.

Reply to this answer
Brin

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.

Reply to this answer
_a75~ferrulevisor.3

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.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions