MagicStack / MagicPython

Cutting edge Python syntax highlighter for Sublime Text, Atom and Visual Studio Code. Used by GitHub to highlight your Python code!
MIT License
1.4k stars 91 forks source link

Equals operator (==) incorrectly tokenized to two consecutive assignments #43

Closed dokai closed 8 years ago

dokai commented 8 years ago

I encountered an issue with tokenizing the equals operator, ==, which gets tokenized as two consecutive assignment operations due to the latter getting precedence. The effect can be seen when using a font containing programming ligatures (such as Fira Code) where the equals operator fails to render correctly.

https://github.com/dokai/MagicPython/commit/d7cdae93de9283b3e8df7c6612aefd59377f612a contains a test case which demonstrates the issue and fails accordingly.

1st1 commented 8 years ago

Thanks for reporting this, we'll take a look.

dokai commented 8 years ago

Thanks, here's the output of the failing test I forgot to include originally.

make test                                                                                                                                            
./node_modules/.bin/syntaxdev build-plist --in grammars/src/MagicPython.syntax.yaml --out grammars/MagicPython.tmLanguage
./node_modules/.bin/syntaxdev build-plist --in grammars/src/MagicRegExp.syntax.yaml --out grammars/MagicRegExp.tmLanguage
./node_modules/.bin/syntaxdev build-cson --in grammars/src/MagicPython.syntax.yaml --out grammars/MagicPython.cson
./node_modules/.bin/syntaxdev build-cson --in grammars/src/MagicRegExp.syntax.yaml --out grammars/MagicRegExp.cson
./node_modules/.bin/syntaxdev scopes --syntax grammars/src/MagicPython.syntax.yaml > misc/scopes
./node_modules/.bin/syntaxdev test --tests test/**/*.py --syntax grammars/src/MagicPython.syntax.yaml
--------
184 tests; grammar: grammars/src/MagicPython.syntax.yaml
--------
...............................................................................E........................................................................................................
--------
183 passed; 1 failed.
--------
--------
Failed test test/expressions/expr20.py: Output different from expected
--------
 a             : source.python
               : source.python
-==            : keyword.operator.comparison.python, source.python
+=             : keyword.operator.assignment.python, source.python
+=             : keyword.operator.assignment.python, source.python
               : source.python
 b             : source.python
 a             : source.python
               : source.python
make: *** [test] Error 1
vpetrovykh commented 8 years ago

This is now fixed and should be available in the next version shortly. Thanks again for reporting this bug.

1st1 commented 8 years ago

I've just released v0.5.11. @dokai please test.

1st1 commented 8 years ago

Closing this one. Thanks for reporting the issue!