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

Error List doesn't refresh after creating a new project #7534

Closed
linette-zyy opened this issue Apr 26, 2023 · 3 comments
Closed

Error List doesn't refresh after creating a new project #7534

linette-zyy opened this issue Apr 26, 2023 · 3 comments
Assignees
Labels
bug fixed in next version A fix has been implemented an will appear in an upcoming version

Comments

@linette-zyy
Copy link

Environment
image

Steps to Reproduce
1.Create a python project
2.Type some problematic code in default file
3.File->New->Project
4.Check the Error List

Expected behavior
Error List should not display any error and warnings

Actual behavior
Error List doesn't refresh and still exist previous project's error and warnings

Additional context and screenshots
errorlist_not_refresh

@StellaHuang95 StellaHuang95 added needs investigation Could be an issue - needs investigation and removed needs triage labels Apr 26, 2023
@StellaHuang95
Copy link
Contributor

Per LSP spec, diagnostics notifications are sent from the server to the client to signal results of validation runs.

Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary. The following rule is used for VS Code servers that generate diagnostics:

  • if a language is single file only (for example HTML) then diagnostics are cleared by the server when the file is closed. Please note that open / close events don’t necessarily reflect what the user sees in the user interface. These events are ownership events. So with the current version of the specification it is possible that problems are not cleared although the file is not visible in the user interface since the client has not closed the file yet.

  • if a language has a project system (for example C#) diagnostics are not cleared when a file closes. When a project is opened all diagnostics for all files are recomputed (or read from a cache).

When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the client. If the computed set is empty it has to push the empty array to clear former diagnostics. Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens on the client side.

Right now pylance server seems to do its job, now investigating if the client overwrites the diagnostics everytime it receives new ones.

@StellaHuang95 StellaHuang95 added bug and removed needs investigation Could be an issue - needs investigation labels Sep 14, 2023
@StellaHuang95
Copy link
Contributor

By observing the VS LSP file logger live telemetry, on solution/project close, workspace/didChangeWorkspaceFolders with params.event.removed = workspace is sent out first, then textDocument/didClose gets sent, then server shuts down.

Because of the sequence of the messages, and the fact that pylance only sends empty diagnostics on file close, pylance is not able to find files that belong to the workspace after workspaceRemove.

This doesn't repro in the single root workspace scenario in vscode because vscode just disposes the old workspace and re-creates a new one on workspace open.

This repros both in VS and the multi-root workspace scenario in vscode. To repro in vscode:

  1. Add "python.analysis.diagnosticMode": "workspace" to workspace.json
  2. remove one folder from workspace
  3. diagnostics of the files from the removed folder are still displayed

@StellaHuang95
Copy link
Contributor

This should be fixed once Pylance ships the fix in stable.

@StellaHuang95 StellaHuang95 added the fixed in next version A fix has been implemented an will appear in an upcoming version label Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fixed in next version A fix has been implemented an will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

2 participants