From 1d1eea217d5b674e6cad77704f912a3a76505d70 Mon Sep 17 00:00:00 2001 From: Emil Lauridsen Date: Fri, 10 Jan 2020 22:10:26 +0100 Subject: Slightly more robust cargo watcher root search --- crates/ra_lsp_server/src/world.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 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 121ddfd1f..36b5242d1 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -74,7 +74,7 @@ impl WorldState { lru_capacity: Option, exclude_globs: &[Glob], watch: Watch, - options: Options, + mut options: Options, feature_flags: FeatureFlags, ) -> WorldState { let mut change = AnalysisChange::new(); @@ -132,8 +132,20 @@ impl WorldState { change.set_crate_graph(crate_graph); // FIXME: Figure out the multi-workspace situation - let check_watcher = - CheckWatcher::new(&options.cargo_watch, folder_roots.first().cloned().unwrap()); + let check_watcher = { + let first_workspace = workspaces.first().unwrap(); + let cargo_project_root = match first_workspace { + ProjectWorkspace::Cargo { cargo, .. } => cargo.workspace_root.clone(), + 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 mut analysis_host = AnalysisHost::new(lru_capacity, feature_flags); analysis_host.apply_change(change); -- cgit v1.2.3