Open hologerry opened 1 month ago
This is likely coming from MagicPython. Just in case this is not, moving to pylance.
Hi, @karthiknadig thanks! Hope we can have a solution to this.
I don't think this is an actual bug. You'd have to change the theme.
That character is identified as keyword.operator.arithmetic
The same as *
So -
counts as an operator.
So
-
counts as an operator.
Counts as an operator in what sense? I see that the TextMate grammar is treating it that way, but I don't think that's true from Python's perspective.
Here's what I see in the Python grammar, which indicates that negative numbers are literals.
literal_pattern:
| signed_number !('+' | '-')
| complex_number
| strings
| 'None'
| 'True'
| 'False'
...
signed_number:
| NUMBER
| '-' NUMBER
Then for fun I tried https://github.com/iritkatriel/codoscope and it also indicates that there's no operator call involved here:
Wouldn't the UNARY_NEGATIVE be the operator? Oh I guess that was on X, but not 1. So for -1
it should be a literal but for -x
there is an operator involved.
Yeah, I added the y = -x
line to compare the two scenarios. Sorry that wasn't clear. The highlighted bytecode instructions on the right side are the entirety of the bytecode for x = -1
.
Reopening since this is a bug. However, @hologerry, be aware that it may not get fixed anytime soon. See https://github.com/microsoft/pylance-release/issues/5824 for some context.
Hi @debonte, Thanks for clarifying this! It’s great to know, and I hope we can get a better syntax highlighter in the future.
I am using latest VS Code and Python/Pylance extension on macOS. The color theme is the Dracula https://github.com/dracula/visual-studio-code The minus symbol
-
is not highligted with the numbers.I suggest to add something like this -? at the begin of this regexp. Like this: (-?[0-9]+) A similar issue of other extension: https://github.com/hashicorp/vscode-terraform/issues/243