Skip to content

Commit

Permalink
Auto merge of rust-lang#13603 - Veykril:no-workspaces, r=Veykril
Browse files Browse the repository at this point in the history
fix: Send status notification if there are no found workspaces

Closes rust-lang/rust-analyzer#5829
  • Loading branch information
bors committed Nov 11, 2022
2 parents 599142c + e35836e commit ff78d24
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions crates/rust-analyzer/src/reload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit ff78d24

Please sign in to comment.