0

Does anyone know what could cause VS Code to suddenly have syntax highlighting go haywire, and autocompletion/intellisense stop working? I have tried reinstalling VS Code, switching to the VS Code insiders version, disabling unused extensions. No matter what I do a few minutes after opening VS code highlighting goes nuts and Pylance intellisense drops out.

For example:

enter image description here

enter image description here

The only unusual thing I see in the language server output is:

2023-08-10 09:35:08.006 [info] Error: Debug Failure. False expression: Chained file path undefined doesn't match cellFilePaths c:\Users\julian.irwin\OneDrive - Thermo Fisher Scientific\Projects\XXXX\python notebooks\xxxxxxxxx\lamp_noise_study.ipynb:pylance-notebook-cell:X15sZmlsZQ==.py
    at _0x2f5209 (c:\Users\julian.irwin\.vscode-insiders\extensions\ms-python.vscode-pylance-2023.8.20\dist\server.bundle.js:1:1017323)
    at c:\Users\julian.irwin\.vscode-insiders\extensions\ms-python.vscode-pylance-2023.8.20\dist\server.bundle.js:1:1024550
    at _0x3100be.<computed> (c:\Users\julian.irwin\.vscode-insiders\extensions\ms-python.vscode-pylance-2023.8.20\dist\server.bundle.js:1:1024582)
    at _0x72f7ac._onDidChangeNotebookDocumentAsync (c:\Users\julian.irwin\.vscode-insiders\extensions\ms-python.vscode-pylance-2023.8.20\dist\server.bundle.js:1:1003431)

Much of the language server output has path names containing sensitive information so I didn't post the full output. I can scrub and then post them if it would help someone debug this.

Another mysterious fact is that a python file (.py) opened in a different tab works fine. Highlighting and autocompletion are fully function. It is only in the notebook environment that the problem occurs.

Possibly related to this Pylance issue: https://github.com/microsoft/pylance-release/issues/4685

Suggested solution is to downgrade to Pylance v2023.7.40

Versions:

windows 11
vscode 1.81.0
vscode 1.82.0-insider (also tried with this one!)
python 3.11.1
ipykernel   6.19.4

VSCode Extensions

Jupyter v2023.7.1002162226
Python v2023.14.0
Pylance v2023.8.20
Julian Irwin
  • 172
  • 10
  • 1
    Have you selected a python kernel for the notebook yet? Your python 3.11.1? – starball Aug 11 '23 at 19:04
  • 1
    If you selected a kernel and if this was working fine before, I might actually suggest that you raise a bug report about this. You can use the `Help > Report Issue` menu item in VS Code. If you do this, once your issue ticket is created, please ping me with a link to it. Make sure to provide the maintainers with as much detail as possible (see also the instructions for providing a [mre]) – starball Aug 11 '23 at 19:05
  • @starball I have managed to find a recent Pylance issue on this topic so I am not going to open a new one at this point. If I can deduce the minimum steps to repro this bug and they are different from the existing issue(s), I will file a new one. https://github.com/microsoft/pylance-release/issues/4685 – Julian Irwin Aug 14 '23 at 17:58
  • 1
    note that there is a Q&A on that GitHub issue already: https://stackoverflow.com/q/76874235/11107541 – starball Aug 14 '23 at 18:06

2 Answers2

0

I found the solution. In my case, some file was corrupted. Find the location of the extension folder which is showing an error.

  1. Uninstall all Python extensions
  2. Close VS Code
  3. Delete that error extension folder
  4. Open VS Code and install the recommendations

I noted that only uninstalling extension did not delete the folder, so I am guessing that when reinstall, it just loads from the same files again.

  • 1
    Thank you for the suggestion. Unfortunately this did not work. I uninstalled VS Code and deleted the ".vs_code" folder in my home folder, which is the folder containing extensions. Upon reinstallation of VS Code and of the python extensions, the problem is still happening. – Julian Irwin Aug 14 '23 at 14:36
0

The problem is addressed in this Pylance issue:

https://github.com/microsoft/pylance-release/issues/4685

The solution is to downgrade from Pyalnce v2023.8.xx to v2023.7.40, using the "Install" or "Uninstall" pulldown menu in the VS Code extension listing for Pylance.

Julian Irwin
  • 172
  • 10