Skip to content

Commit ff78d24

Browse files
committed
Auto merge of rust-lang#13603 - Veykril:no-workspaces, r=Veykril
fix: Send status notification if there are no found workspaces Closes rust-lang/rust-analyzer#5829
2 parents 599142c + e35836e commit ff78d24

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Diff for: crates/rust-analyzer/src/reload.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ impl GlobalState {
106106
status.health = lsp_ext::Health::Error;
107107
status.message = Some(error)
108108
}
109+
110+
if self.config.linked_projects().is_empty()
111+
&& self.config.detached_files().is_empty()
112+
&& self.config.notifications().cargo_toml_not_found
113+
{
114+
status.health = lsp_ext::Health::Warning;
115+
status.message = Some("Workspace reload required".to_string())
116+
}
109117
status
110118
}
111119

@@ -427,9 +435,14 @@ impl GlobalState {
427435
fn fetch_workspace_error(&self) -> Result<(), String> {
428436
let mut buf = String::new();
429437

430-
for ws in self.fetch_workspaces_queue.last_op_result() {
431-
if let Err(err) = ws {
432-
stdx::format_to!(buf, "rust-analyzer failed to load workspace: {:#}\n", err);
438+
let last_op_result = self.fetch_workspaces_queue.last_op_result();
439+
if last_op_result.is_empty() {
440+
stdx::format_to!(buf, "rust-analyzer failed to discover workspace");
441+
} else {
442+
for ws in last_op_result {
443+
if let Err(err) = ws {
444+
stdx::format_to!(buf, "rust-analyzer failed to load workspace: {:#}\n", err);
445+
}
433446
}
434447
}
435448

0 commit comments

Comments
 (0)