aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-11-26 12:42:29 +0000
committerGitHub <[email protected]>2020-11-26 12:42:29 +0000
commit0bcd8147ec08db2a94dd2a3068a527ba6c47a4cd (patch)
treef234e1cb10f8f94c845f4939119d40a18e5f2069
parentdb6988d4e7646c09dc882fddcd5d9cf74f467276 (diff)
parent9ed883f3735e15deb04e9123b6f3fd3aef68d8cd (diff)
Merge #6637
6637: Publish diagnostics on file open r=jonas-schievink a=jonas-schievink Diagnostics are sometimes only showing up when typing. This should fix that. Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6381 Co-authored-by: Jonas Schievink <[email protected]>
-rw-r--r--crates/rust-analyzer/src/main_loop.rs17
1 files changed, 9 insertions, 8 deletions
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 {
348 } 348 }
349 349
350 if self.status == Status::Ready && (state_changed || prev_status == Status::Loading) { 350 if self.status == Status::Ready && (state_changed || prev_status == Status::Loading) {
351 let subscriptions = self 351 self.update_file_notifications_on_threadpool();
352 .mem_docs
353 .keys()
354 .map(|path| self.vfs.read().0.file_id(&path).unwrap())
355 .collect::<Vec<_>>();
356
357 self.update_file_notifications_on_threadpool(subscriptions);
358 352
359 // Refresh semantic tokens if the client supports it. 353 // Refresh semantic tokens if the client supports it.
360 if self.config.semantic_tokens_refresh { 354 if self.config.semantic_tokens_refresh {
@@ -498,6 +492,7 @@ impl GlobalState {
498 .write() 492 .write()
499 .0 493 .0
500 .set_file_contents(path, Some(params.text_document.text.into_bytes())); 494 .set_file_contents(path, Some(params.text_document.text.into_bytes()));
495 this.update_file_notifications_on_threadpool();
501 } 496 }
502 Ok(()) 497 Ok(())
503 })? 498 })?
@@ -606,7 +601,13 @@ impl GlobalState {
606 .finish(); 601 .finish();
607 Ok(()) 602 Ok(())
608 } 603 }
609 fn update_file_notifications_on_threadpool(&mut self, subscriptions: Vec<FileId>) { 604 fn update_file_notifications_on_threadpool(&mut self) {
605 let subscriptions = self
606 .mem_docs
607 .keys()
608 .map(|path| self.vfs.read().0.file_id(&path).unwrap())
609 .collect::<Vec<_>>();
610
610 log::trace!("updating notifications for {:?}", subscriptions); 611 log::trace!("updating notifications for {:?}", subscriptions);
611 if self.config.publish_diagnostics { 612 if self.config.publish_diagnostics {
612 let snapshot = self.snapshot(); 613 let snapshot = self.snapshot();