mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-26 05:44:26 +00:00
Clear diagnostics for known file version on close
This commit is contained in:
parent
97927146db
commit
79a3dd085c
@ -432,19 +432,26 @@ impl GlobalState {
|
||||
Ok(())
|
||||
})?
|
||||
.on::<lsp_types::notification::DidCloseTextDocument>(|this, params| {
|
||||
let mut version = None;
|
||||
if let Ok(path) = from_proto::vfs_path(¶ms.text_document.uri) {
|
||||
if this.mem_docs.remove(&path).is_none() {
|
||||
log::error!("orphan DidCloseTextDocument: {}", path)
|
||||
match this.mem_docs.remove(&path) {
|
||||
Some(entry) => version = entry,
|
||||
None => log::error!("orphan DidCloseTextDocument: {}", path),
|
||||
}
|
||||
|
||||
if let Some(path) = path.as_path() {
|
||||
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::notification::PublishDiagnostics>(
|
||||
lsp_types::PublishDiagnosticsParams {
|
||||
uri: params.text_document.uri,
|
||||
diagnostics: Vec::new(),
|
||||
version: None,
|
||||
version,
|
||||
},
|
||||
);
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user