about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2022-11-11 13:00:22 +0100
committerLukas Wirth <lukastw97@gmail.com>2022-11-11 13:00:22 +0100
commite35836eb811a99872fdf63f1f0f1046ee651eeb0 (patch)
tree6850d15d39a391e5d44187363c1a86f3a502903f
parent599142c34abad1442994947bd1200ce0bc973c54 (diff)
downloadrust-e35836eb811a99872fdf63f1f0f1046ee651eeb0.tar.gz
rust-e35836eb811a99872fdf63f1f0f1046ee651eeb0.zip
Send status notification if there are no found workspaces
-rw-r--r--crates/rust-analyzer/src/reload.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index e1f651786de..407416d9f40 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -106,6 +106,14 @@ impl GlobalState {
             status.health = lsp_ext::Health::Error;
             status.message = Some(error)
         }
+
+        if self.config.linked_projects().is_empty()
+            && self.config.detached_files().is_empty()
+            && self.config.notifications().cargo_toml_not_found
+        {
+            status.health = lsp_ext::Health::Warning;
+            status.message = Some("Workspace reload required".to_string())
+        }
         status
     }
 
@@ -427,9 +435,14 @@ impl GlobalState {
     fn fetch_workspace_error(&self) -> Result<(), String> {
         let mut buf = String::new();
 
-        for ws in self.fetch_workspaces_queue.last_op_result() {
-            if let Err(err) = ws {
-                stdx::format_to!(buf, "rust-analyzer failed to load workspace: {:#}\n", err);
+        let last_op_result = self.fetch_workspaces_queue.last_op_result();
+        if last_op_result.is_empty() {
+            stdx::format_to!(buf, "rust-analyzer failed to discover workspace");
+        } else {
+            for ws in last_op_result {
+                if let Err(err) = ws {
+                    stdx::format_to!(buf, "rust-analyzer failed to load workspace: {:#}\n", err);
+                }
             }
         }