Skip to content

Commit 8ed9724

Browse files
Do not erase Cargo diagnostics from the closed documents
1 parent 2e52d6e commit 8ed9724

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -633,11 +633,9 @@ impl GlobalState {
633633
Ok(())
634634
})?
635635
.on::<lsp_types::notification::DidCloseTextDocument>(|this, params| {
636-
let mut version = None;
637636
if let Ok(path) = from_proto::vfs_path(&params.text_document.uri) {
638-
match this.mem_docs.remove(&path) {
639-
Some(doc) => version = Some(doc.version),
640-
None => log::error!("orphan DidCloseTextDocument: {}", path),
637+
if this.mem_docs.remove(&path).is_none() {
638+
log::error!("orphan DidCloseTextDocument: {}", path);
641639
}
642640

643641
this.semantic_tokens_cache.lock().remove(&params.text_document.uri);
@@ -646,17 +644,6 @@ impl GlobalState {
646644
this.loader.handle.invalidate(path.to_path_buf());
647645
}
648646
}
649-
650-
// Clear the diagnostics for the previously known version of the file.
651-
// This prevents stale "cargo check" diagnostics if the file is
652-
// closed, "cargo check" is run and then the file is reopened.
653-
this.send_notification::<lsp_types::notification::PublishDiagnostics>(
654-
lsp_types::PublishDiagnosticsParams {
655-
uri: params.text_document.uri,
656-
diagnostics: Vec::new(),
657-
version,
658-
},
659-
);
660647
Ok(())
661648
})?
662649
.on::<lsp_types::notification::DidSaveTextDocument>(|this, params| {

0 commit comments

Comments
 (0)