Re-Adding Workspaces to the Language Server should retrigger Diagnostic generation
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
**Describe the bug**
This bug is also related to my attempt of integrating Pyright with Eclipse via lsp4e.
The Language Server is initialized with a bunch workspace folders which all have the following structure:
```
Test/foo.py
bar.py
```
`foo.py`:
```
x = 5
```
`bar.py`:
```
from Test.foo import x
print(x)
```
When `bar.py` is opened, a `textDocument/didOpen` is sent to the server, which triggers background validation. Shortly after that, the client sends a `workspace/didChangeWorkspaceFolders` which contains all Workspace folders again, because lsp4e wants to make sure, that the server knows about all workspace folders. This causes pyright to remove and re-add all existing workspaces which in turn seems to cause some race condition with the ongoing analysis, because the open document is then associated with the "default" workspace where the analysis can't find the namespace package 'Test' and thus generates a `reportMissingImports` error.
It also logs the error `[Error] File or directory "\" does not exist.`
It would be nice if the removal/re-adding of the workspace folders would retrigger the analysis for files which belong or belonged to an affected workspace.
**VS Code extension or command-line**
I'm using Pyright 1.1.407 through the unofficial Python package
Contributor guide
Research direction
Start by reproducing the sequence of opening bar.py, then sending workspace/didChangeWorkspaceFolders with the existing folders again. Trace how workspace removal and re-adding interacts with background validation and the default workspace; done means affected files are analyzed again, the Test namespace resolves without a reportMissingImports error, and the default workspace error is absent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100