Skip to content

Commit

Permalink
LSP: Properly discard out-of-date diagnostics
Browse files Browse the repository at this point in the history
Previously the `filter` caused the diagnostics to not be attached to the
document - which is good - but the out-of-date diagnostics were still
inserted into the global (editor-wide) diagnostic set. Instead we should
completely discard out-of-date diagnostics.
  • Loading branch information
the-mikedavis committed Feb 4, 2025
1 parent 62625ed commit 313a647
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions helix-view/src/handlers/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,17 @@ impl Editor {
version: Option<i32>,
mut diagnostics: Vec<lsp::Diagnostic>,
) {
let doc = self.documents.values_mut()
.find(|doc| doc.uri().is_some_and(|u| u == uri))
.filter(|doc| {
if let Some(version) = version {
if version != doc.version() {
log::info!("Version ({version}) is out of date for {uri:?} (expected ({}), dropping PublishDiagnostic notification", doc.version());
return false;
}
}
true
});
let doc = self
.documents
.values_mut()
.find(|doc| doc.uri().is_some_and(|u| u == uri));

if let Some((version, doc)) = version.zip(doc.as_ref()) {
if version != doc.version() {
log::info!("Version ({version}) is out of date for {uri:?} (expected ({})), dropping PublishDiagnostic notification", doc.version());
return;
}
}

let mut unchanged_diag_sources = Vec::new();
if let Some((lang_conf, old_diagnostics)) = doc
Expand Down

0 comments on commit 313a647

Please sign in to comment.