vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Syntax highlighting issue when @ appears as first character after line continuation when indexing is present

Open tillahoffmann opened this issue 3 years ago • 4 comments

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

image

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

tillahoffmann avatar Dec 07 '21 22:12 tillahoffmann

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.

erictraut avatar Dec 08 '21 17:12 erictraut

Yes, agreed, @erictraut. Are you able to transfer back to microsoft/vscode-python, @karthiknadig?

tillahoffmann avatar Dec 08 '21 18:12 tillahoffmann

TextMate grammar is in the VS Code repo not in the python extension. We should move this there.

karthiknadig avatar Dec 08 '21 18:12 karthiknadig

Aha, my bad. Thanks for clarifying.

tillahoffmann avatar Dec 08 '21 18:12 tillahoffmann

Copied to the upstream repo that we pull the python grammar from: https://github.com/MagicStack/MagicPython/issues/253

alexr00 avatar Sep 23 '22 09:09 alexr00