mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 15:15:33 +00:00
ruff server
: In 'publish diagnostics' mode, document diagnostics are 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`](187d7790be/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.
This commit is contained in:
parent
19baabba58
commit
4690890e9f
2 changed files with 31 additions and 1 deletions
|
@ -32,3 +32,20 @@ pub(super) fn publish_diagnostics_for_document(
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn clear_diagnostics_for_document(
|
||||
snapshot: &DocumentSnapshot,
|
||||
notifier: &Notifier,
|
||||
) -> crate::server::Result<()> {
|
||||
notifier
|
||||
.notify::<lsp_types::notification::PublishDiagnostics>(
|
||||
lsp_types::PublishDiagnosticsParams {
|
||||
uri: snapshot.url().clone(),
|
||||
diagnostics: vec![],
|
||||
version: Some(snapshot.document().version()),
|
||||
},
|
||||
)
|
||||
.with_failure_code(lsp_server::ErrorCode::InternalError)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue