SublimeText / PowerShell

Support for the MS PowerShell programming language.
MIT License
313 stars 78 forks source link

Operators Not Allowing Preceding Word Characters #79

Closed bcrotty closed 6 years ago

bcrotty commented 9 years ago

2015-01-29 09_52_14-greenshot

The following scopes all do not allow any word characters before them, which does not allow for the above legal syntax. The current syntax does correctly catch that the last example is wrong.

keyword.operator.comparison.powershell
keyword.operator.comparison.powershell
keyword.operator.unary.powershell
keyword.operator.logical.powershell
keyword.operator.bitwise.powershell

The three valid cases I've found are:

  1. Preceded by a number
  2. Preceded by a variable (possibly with properties/methods)
  3. Preceded by another operator or an operator with a value (e.g. 1-or1-gt2)

If you remove the check for preceding word characters, the syntax correctly identifies all but the last example, which it incorrectly allows.

2015-01-29 09_51_51-c__users_bcrotty_skydrive_script archive_powershell syntax test ps1 powershel

vors commented 9 years ago

It one of these things, that pretty hard to implement correctly. I prefer the current behavior: there may be some correct command names like Get-Contains or Get-Join, which will incorrectly highlighted when preceding word character removed. On the other hand $a-clt2 is a pretty unreadable programming style and I hope people don't write such code often.

bcrotty commented 9 years ago

I agree, but shouldn't the syntax mirror what PowerShell and the ISE actually do?

vors commented 9 years ago

Yes, we should try to follow it. My point is, the second option is less preferable, because it confuses people with good programming style.

Ideally we should fix it, but I don't know how much work is it. Maybe you can take a look? :)

bcrotty commented 9 years ago

Planning on it :) Just wanted to document it.

vors commented 6 years ago

Closing in favor of https://github.com/PowerShell/EditorSyntax