Skip to content

Fix operators followed immediately by numbers #206

@michaelblyons

Description

@michaelblyons

The word break problem shows up on other keyword-prefixes (like -bxor)
I investigated it and there is a simple fix: add \b for word boundary

https://github.com/SublimeText/PowerShell/blob/dev/Support/PowershellSyntax.tmLanguage#L265

-           <string>-(?i:and|or|not|xor)|!</string>
+           <string>-(?i:and|or|not|xor)\b|!</string>

The tricky part that it's not a 100% accurate fix. In PS it's legal to write -not1 and 1-bxor1, without spaces.

A proper fix will be relatively complicated: we need to recognize that context implies function call and turn-off keyword highlighting for all -bla keywords. It's pretty easy to introduce new bugs, when implementing this, so I would prefer implement it with reasonable test coverage.

PS: -not1 ideally should be recognized correctly (highlight -not part), but I have no idea how to do it without using PS parser or over-engineering.

Originally posted by @vors in #23

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions