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

ruff server: publishDiagnostics should be sent on onClose to clear diagnostics #11114

Closed
snowsignal opened this issue Apr 23, 2024 · 0 comments · Fixed by #11137
Closed

ruff server: publishDiagnostics should be sent on onClose to clear diagnostics #11114

snowsignal opened this issue Apr 23, 2024 · 0 comments · Fixed by #11137
Assignees
Labels
server Related to the LSP server

Comments

@snowsignal
Copy link
Contributor

When clients don't support pull diagnostics, we'll need to send them an empty publishDiagnostics notification when a file is closed - otherwise, the previous diagnostics for that file will continue to exist.

Reported by @dhruvmanila here.

@snowsignal snowsignal added the server Related to the LSP server label Apr 23, 2024
@snowsignal snowsignal self-assigned this Apr 23, 2024
snowsignal added a commit that referenced this issue Apr 25, 2024
…e cleared properly when a file is closed (#11137)

## Summary

Fixes #11114. 

As part of the `onClose` handler, we publish an empty array of
diagnostics for the document being closed, similar to
[`ruff-lsp`](https://github.com/astral-sh/ruff-lsp/blob/187d7790be0783b9ac41ce025a724cf389bf575c/ruff_lsp/server.py#L459-L464).
This prevent phantom diagnostics from lingering after a document is
closed. We'll only do this if the client doesn't support pull
diagnostics, because otherwise clearing diagnostics is their
responsibility.

## Test Plan

Diagnostics should no longer appear for a document in the Problems tab
after the document is closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server Related to the LSP server
Projects
None yet
1 participant