]> git.lizzy.rs Git - rust.git/commitdiff
Publish diagnostics on file open
authorJonas Schievink <jonasschievink@gmail.com>
Thu, 26 Nov 2020 12:33:47 +0000 (13:33 +0100)
committerJonas Schievink <jonasschievink@gmail.com>
Thu, 26 Nov 2020 12:33:47 +0000 (13:33 +0100)
Diagnostics are sometimes only showing up when typing.
This should fix that.

crates/rust-analyzer/src/main_loop.rs

index b34ff092d6d4093f5da685be9d87ed8e5763dbb1..470c2e2284e70e905f82c51274002f03a2392b37 100644 (file)
@@ -348,13 +348,7 @@ fn handle_event(&mut self, event: Event) -> Result<()> {
         }
 
         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::<Vec<_>>();
-
-            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 @@ fn on_notification(&mut self, not: Notification) -> Result<()> {
                         .write()
                         .0
                         .set_file_contents(path, Some(params.text_document.text.into_bytes()));
+                    this.update_file_notifications_on_threadpool();
                 }
                 Ok(())
             })?
@@ -606,7 +601,13 @@ fn on_notification(&mut self, not: Notification) -> Result<()> {
             .finish();
         Ok(())
     }
-    fn update_file_notifications_on_threadpool(&mut self, subscriptions: Vec<FileId>) {
+    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::<Vec<_>>();
+
         log::trace!("updating notifications for {:?}", subscriptions);
         if self.config.publish_diagnostics {
             let snapshot = self.snapshot();