vscode
vscode copied to clipboard
Syntax highlighting issue when @ appears as first character after line continuation when indexing is present
VS Code version
1.62.3
Extension version
v2021.11.1422169775
OS type
macOS
OS version
11.6
Python distribution
Other
Python version
pyenv (installed with brew) in virtual environment (3.8.10)
Language server
Default
Expected behaviour
I would expect syntax highlighting to be the same irrespective of whether the line is broken before or after the @ operator.
Actual behaviour
Steps to reproduce
Enter the following code into a new python file.
# Define variables so pylance doesn't complain.
long_variable_name = other_long_variable_name = 1
long_variable_name \
@ other_long_variable_name['some_index']
long_variable_name @ \
other_long_variable_name['some_index']
Logs
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
This is a bug in the TextMate grammar included in the Python extension, not in Pylance. I suspect it's related to the fact that the @ operator is used for decorators, and decorators prior to Python 3.9 could not contain index expressions. In any case, this bug should probably be transferred to the Python extension repo.
Yes, agreed, @erictraut. Are you able to transfer back to microsoft/vscode-python, @karthiknadig?
TextMate grammar is in the VS Code repo not in the python extension. We should move this there.
Aha, my bad. Thanks for clarifying.
Copied to the upstream repo that we pull the python grammar from: https://github.com/MagicStack/MagicPython/issues/253