Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't report Read / Write access for current word under the cursor #42

Closed
jonathanding opened this issue Jul 3, 2020 · 3 comments
Closed
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@jonathanding
Copy link

Environment data

  • Language Server version: 2020.6.1
  • OS and version: Windows 10 Enterprise, Build 18363
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.3 64bit

Expected behaviour

According to https://code.visualstudio.com/api/references/theme-color#editor-colors, the language server should report read/write access for current variable (the word under the cursor), so that theme could assign them with different colors.

This is captured from the official documentation of VSCode.

This does work as expected if using old "Microsoft" language server.

As shown below, the variable "test" is under cursor, and it's write access so rendered as magenta, while the other occurrence of "test" is read access and rendered as blue.

It's magenta and blue because I configured this in my settings as below.

Actual behaviour

However, after switch to Pylance, it doesn't work any more. You would see both occurrences are rendered as green -- this is because language sever doesn't report the access type and it falls back to use the color defined for "selectionHighlightBackground" in my settings above.

Logs

[Info  - 4:49:07 PM] Pylance language server 2020.6.1 starting
[Info  - 4:49:07 PM] Server root directory: c:\Users\jding4\.vscode\extensions\ms-python.vscode-pylance-2020.6.1\server
[Info  - 4:52:00 PM] No configuration file found.
[Info  - 4:52:00 PM] Setting pythonPath for service "fda": "C:\Python\python.exe"
[Info  - 4:52:00 PM] stubPath c:\workspace\fda\typings is not a valid directory.
[Info  - 4:52:00 PM] Assuming Python version 3.8
[Info  - 4:52:00 PM] Assuming Python platform Windows
[Info  - 4:52:00 PM] Searching for source files
[Info  - 4:52:00 PM] Found 1 source file
[BG] analyzing: c:\workspace\fda\test.py ...
[BG]   parsing: c:\workspace\fda\test.py (18ms)
[BG]   parsing: c:\Users\jding4\.vscode\extensions\ms-python.vscode-pylance-2020.6.1\server\typeshed-fallback\stdlib\2and3\builtins.pyi (470ms)
[BG]   binding: c:\Users\jding4\.vscode\extensions\ms-python.vscode-pylance-2020.6.1\server\typeshed-fallback\stdlib\2and3\builtins.pyi (122ms)
[BG]   binding: c:\workspace\fda\test.py (1ms)
[BG]   checking: c:\workspace\fda\test.py ...
[BG]     parsing: c:\Users\jding4\.vscode\extensions\ms-python.vscode-pylance-2020.6.1\server\typeshed-fallback\stdlib\3\typing.pyi (88ms)
[BG]     binding: c:\Users\jding4\.vscode\extensions\ms-python.vscode-pylance-2020.6.1\server\typeshed-fallback\stdlib\3\typing.pyi (33ms)
[BG]     parsing: c:\Users\jding4\.vscode\extensions\ms-python.vscode-pylance-2020.6.1\server\typeshed-fallback\stdlib\2and3\_typeshed\__init__.pyi (17ms)
[BG]     binding: c:\Users\jding4\.vscode\extensions\ms-python.vscode-pylance-2020.6.1\server\typeshed-fallback\stdlib\2and3\_typeshed\__init__.pyi (2ms)
[BG]   checking: c:\workspace\fda\test.py (189ms)
[BG] analyzing: c:\workspace\fda\test.py (802ms)
[FG] parsing: c:\workspace\fda\test.py (47ms)
[FG] parsing: c:\Users\jding4\.vscode\extensions\ms-python.vscode-pylance-2020.6.1\server\typeshed-fallback\stdlib\2and3\builtins.pyi (1031ms)
[FG] binding: c:\Users\jding4\.vscode\extensions\ms-python.vscode-pylance-2020.6.1\server\typeshed-fallback\stdlib\2and3\builtins.pyi (293ms)
[FG] binding: c:\workspace\fda\test.py (5ms)
[FG] parsing: c:\Users\jding4\.vscode\extensions\ms-python.vscode-pylance-2020.6.1\server\typeshed-fallback\stdlib\3\typing.pyi (165ms)
[FG] binding: c:\Users\jding4\.vscode\extensions\ms-python.vscode-pylance-2020.6.1\server\typeshed-fallback\stdlib\3\typing.pyi (90ms)
[FG] parsing: c:\Users\jding4\.vscode\extensions\ms-python.vscode-pylance-2020.6.1\server\typeshed-fallback\stdlib\2and3\_typeshed\__init__.pyi (29ms)
[FG] binding: c:\Users\jding4\.vscode\extensions\ms-python.vscode-pylance-2020.6.1\server\typeshed-fallback\stdlib\2and3\_typeshed\__init__.pyi (3ms

Code Snippet / Additional information

def f():
    test = "Write access for the variable"
    print(test, "Read access for the variable"
@huguesv
Copy link
Contributor

huguesv commented Jul 6, 2020

Looks like it is this LSP request which provides this information in MPLS, but is not supported yet in Pylance: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentHighlight

@huguesv huguesv added the enhancement New feature or request label Jul 6, 2020
@erictraut
Copy link
Contributor

erictraut commented Jul 7, 2020

I implemented this functionality, and it will be included in an upcoming version of Pylance.

@erictraut erictraut added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Jul 7, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.7.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202070-9-july-2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

4 participants