rhaiscript / sublime-rhai

Rhai syntax highlighting for Sublime Text.
Mozilla Public License 2.0
0 stars 0 forks source link

Highlighting breaks when bitwise or operator is used #2

Open bjorn-ove opened 1 year ago

bjorn-ove commented 1 year ago

Thanks for this, I'm using rhai as my Advent og Code challenge when I noticed this issue.

I think it is because of the closure handling. Maybe the order is wrong?

To reproduce just add code with a logical or anywhere and the code until the next logical or is not highlighted.

schungx commented 1 year ago

Thanks for catching this.

This seems to be due to a conflict between the bitwise or operator | and a closure |x, y| ...

This may not be easy to solve... say... foo | bar | baz may be interpreted as: foo, |bar| baz (closure) or foo | bar | baz (operators). Same with || it seems, which is recognized as a closure with no arguments instead of the logical OR operator.

Right now, it favors closures over bitwise OR because bitwise operators are rare. However, you can claim that it is better to favor the logical OR for || over a closure...

I'm not sure if this can be easily resolved without adding complexity to the syntax highlighting...

schungx commented 1 year ago

Calling for someone with the skills to fix this...