diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 82a31362af6..b98827ae76e 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -633,11 +633,9 @@ impl GlobalState { Ok(()) })? .on::(|this, params| { - let mut version = None; if let Ok(path) = from_proto::vfs_path(¶ms.text_document.uri) { - match this.mem_docs.remove(&path) { - Some(doc) => version = Some(doc.version), - None => log::error!("orphan DidCloseTextDocument: {}", path), + if this.mem_docs.remove(&path).is_none() { + log::error!("orphan DidCloseTextDocument: {}", path); } this.semantic_tokens_cache.lock().remove(¶ms.text_document.uri); @@ -646,17 +644,6 @@ impl GlobalState { this.loader.handle.invalidate(path.to_path_buf()); } } - - // Clear the diagnostics for the previously known version of the file. - // This prevents stale "cargo check" diagnostics if the file is - // closed, "cargo check" is run and then the file is reopened. - this.send_notification::( - lsp_types::PublishDiagnosticsParams { - uri: params.text_document.uri, - diagnostics: Vec::new(), - version, - }, - ); Ok(()) })? .on::(|this, params| {