From 9ed883f3735e15deb04e9123b6f3fd3aef68d8cd Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 26 Nov 2020 13:33:47 +0100 Subject: Publish diagnostics on file open Diagnostics are sometimes only showing up when typing. This should fix that. --- crates/rust-analyzer/src/main_loop.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index b34ff092d..470c2e228 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -348,13 +348,7 @@ impl GlobalState { } if self.status == Status::Ready && (state_changed || prev_status == Status::Loading) { - let subscriptions = self - .mem_docs - .keys() - .map(|path| self.vfs.read().0.file_id(&path).unwrap()) - .collect::>(); - - self.update_file_notifications_on_threadpool(subscriptions); + self.update_file_notifications_on_threadpool(); // Refresh semantic tokens if the client supports it. if self.config.semantic_tokens_refresh { @@ -498,6 +492,7 @@ impl GlobalState { .write() .0 .set_file_contents(path, Some(params.text_document.text.into_bytes())); + this.update_file_notifications_on_threadpool(); } Ok(()) })? @@ -606,7 +601,13 @@ impl GlobalState { .finish(); Ok(()) } - fn update_file_notifications_on_threadpool(&mut self, subscriptions: Vec) { + fn update_file_notifications_on_threadpool(&mut self) { + let subscriptions = self + .mem_docs + .keys() + .map(|path| self.vfs.read().0.file_id(&path).unwrap()) + .collect::>(); + log::trace!("updating notifications for {:?}", subscriptions); if self.config.publish_diagnostics { let snapshot = self.snapshot(); -- cgit v1.2.3