From 480c44918c73922b134b670cbd33014b8fcfc883 Mon Sep 17 00:00:00 2001 From: Emil Lauridsen Date: Sat, 11 Jan 2020 21:32:40 +0100 Subject: Disable cargo checking in workspaces with no cargo projects --- crates/ra_lsp_server/src/world.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index cea18937f..a52bd2633 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -132,20 +132,20 @@ impl WorldState { change.set_crate_graph(crate_graph); // FIXME: Figure out the multi-workspace situation - let check_watcher = { - let first_workspace = workspaces.first().unwrap(); - let cargo_project_root = match first_workspace { - ProjectWorkspace::Cargo { cargo, .. } => cargo.workspace_root().to_path_buf(), - ProjectWorkspace::Json { .. } => { - log::warn!( - "Cargo check watching only supported for cargo workspaces, disabling" - ); - options.cargo_watch.enable = false; - PathBuf::new() - } - }; - CheckWatcher::new(&options.cargo_watch, cargo_project_root) - }; + let check_watcher = workspaces + .iter() + .find_map(|w| match w { + ProjectWorkspace::Cargo { cargo, .. } => Some(cargo), + ProjectWorkspace::Json { .. } => None, + }) + .map(|cargo| { + let cargo_project_root = cargo.workspace_root().to_path_buf(); + CheckWatcher::new(&options.cargo_watch, cargo_project_root) + }) + .unwrap_or_else(|| { + log::warn!("Cargo check watching only supported for cargo workspaces, disabling"); + CheckWatcher::dummy() + }); let mut analysis_host = AnalysisHost::new(lru_capacity, feature_flags); analysis_host.apply_change(change); -- cgit v1.2.3