Improve support for multiple registrations of textDocument/diagnostic (#43703)

Closes https://github.com/zed-industries/zed/issues/41935

The registration ID responsible for generating each diagnostic is now
tracked. This allows us to replace only the diagnostics from the same
registration ID when a pull diagnostics report is applied.

Additionally, various deficiencies in our support for pull diagnostics
have been fixed:
- Document pulls are issued for all open buffers, not just the edited
one. A shorter debounce is used for the edited buffer. Workspace
diagnostics are also now ignored for open buffers.
- Tracking of `lastResultId` is improved.
- Stored pull diagnostics are discarded when the corresponding buffer is
closed.

Release Notes:

- Improved compatibility with language servers that use the "pull
diagnostics" feature of Language Server Protocol.

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
This commit is contained in:
John Tur
2025-12-03 20:47:43 +02:00
committed by GitHub
co-authored by Kirill Bulatov Kirill Bulatov
parent 493cfadb42
commit a51e975b81
13 changed files with 524 additions and 263 deletions
+3
View File
@@ -237,6 +237,8 @@ struct SelectionSet {
pub struct Diagnostic {
/// The name of the service that produced this diagnostic.
pub source: Option<String>,
/// The ID provided by the dynamic registration that produced this diagnostic.
pub registration_id: Option<SharedString>,
/// A machine-readable code that identifies this diagnostic.
pub code: Option<NumberOrString>,
pub code_description: Option<lsp::Uri>,
@@ -5390,6 +5392,7 @@ impl Default for Diagnostic {
is_unnecessary: false,
underline: true,
data: None,
registration_id: None,
}
}
}