PowerShell / EditorSyntax

PowerShell syntax highlighting for editors (VS Code, Atom, SublimeText, TextMate, etc.) and GitHub!
MIT License
133 stars 45 forks source link

Fixes for automatic variables #166

Closed msftrncs closed 5 years ago

msftrncs commented 5 years ago

Fixes #133.

This corrects the regex used for matching $$, $^ and $? automatic variables. This occurs because the current regex can be simplified to \$[$^?]\b, but the \b (word boundary) fails if one of the two characters tested at the boundary is not a word character (one must be a word, one must not be a word, and the set [$^?] contains no word characters). As such, only very limited cases would have successfully matched. A boundary test is not required for these particular patterns. $_ is not affected because _ is a word character, and so it has been left in the part of the regex that still applies the boundary test (and is actually required).

This also fixes the mismatch of scopes for these same variables and the larger set specified in the same regex(s), between #variable and #variableNoProperty, by adopting support.variable.automatic.powershell in both places.

Tests have been corrected for the scope change, and then updated to include tests specific to the two conditions being resolved.