PowerShell / EditorSyntax

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

empty string (double-quoted) in attribute argument highlights as character escape #168

Closed msftrncs closed 5 years ago

msftrncs commented 5 years ago

Surprisingly related to #143, an empty double-quoted string contained in an attribute argument will appear as an escaped double-quote.

image

It will be resolved by the fix for #143, but there are other reasons it is happening.

https://github.com/PowerShell/EditorSyntax/blob/cf27d6e54ff9fc593bfb46d22a671898fb31c0a9/PowerShellSyntax.tmLanguage#L468-L509

In the shown code snippet, the #doubleQuotedStringEscapes appears before #doubleQuotedString. However, the fact is that all of these "includes" seem to be made pointless by the last one, $self because they are all also included in $self (except #variableNoProperty, but nothing that's in #variableNoProperty isn't already covered in #variable). Usually including a specific item, and then including $self would be done when something needs to trigger in a different order, but here there seems to be no reason for it. It probably progressively became this way, while trying to get everything to work, and when the last include $self was added, the others were never cleaned up. This is evident in a few other places as well (sometimes in reverse order). Cleaning these up would improve performance of the syntax.

Admittedly this is obscure because there is seldom any use in an empty double-quoted string value for a attribute argument.