about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/rust-analyzer/src/main_loop.rs4
-rw-r--r--crates/rust-analyzer/src/reload.rs9
2 files changed, 9 insertions, 4 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index e305fe408e6..3ac64e66b52 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -236,7 +236,7 @@ impl GlobalState {
                                     self.fetch_workspaces_queue.op_completed(workspaces);
 
                                     let old = Arc::clone(&self.workspaces);
-                                    self.switch_workspaces();
+                                    self.switch_workspaces("fetched workspace".to_string());
                                     let workspaces_updated = !Arc::ptr_eq(&old, &self.workspaces);
 
                                     if self.config.run_build_scripts() && workspaces_updated {
@@ -259,7 +259,7 @@ impl GlobalState {
                                 BuildDataProgress::End(build_data_result) => {
                                     self.fetch_build_data_queue.op_completed(build_data_result);
 
-                                    self.switch_workspaces();
+                                    self.switch_workspaces("fetched build data".to_string());
 
                                     (Some(Progress::End), None)
                                 }
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index d4e40d807d0..b68f9d5f59d 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -166,9 +166,9 @@ impl GlobalState {
         });
     }
 
-    pub(crate) fn switch_workspaces(&mut self) {
+    pub(crate) fn switch_workspaces(&mut self, cause: Cause) {
         let _p = profile::span("GlobalState::switch_workspaces");
-        tracing::info!("will switch workspaces");
+        tracing::info!(%cause, "will switch workspaces");
 
         if let Err(error_message) = self.fetch_workspace_error() {
             self.show_and_log_error(error_message, None);
@@ -224,6 +224,8 @@ impl GlobalState {
         if same_workspaces {
             let (workspaces, build_scripts) = self.fetch_build_data_queue.last_op_result();
             if Arc::ptr_eq(workspaces, &self.workspaces) {
+                tracing::debug!("set build scripts to workspaces");
+
                 let workspaces = workspaces
                     .iter()
                     .cloned()
@@ -237,11 +239,14 @@ impl GlobalState {
                 // Workspaces are the same, but we've updated build data.
                 self.workspaces = Arc::new(workspaces);
             } else {
+                tracing::info!("build scrips do not match the version of the active workspace");
                 // Current build scripts do not match the version of the active
                 // workspace, so there's nothing for us to update.
                 return;
             }
         } else {
+            tracing::debug!("abandon build scripts for workspaces");
+
             // Here, we completely changed the workspace (Cargo.toml edit), so
             // we don't care about build-script results, they are stale.
             self.workspaces = Arc::new(workspaces)