Skip to content

Commit bbe59c7

Browse files
Reload watcher configuration
1 parent 8a23bec commit bbe59c7

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

crates/rust-analyzer/src/world.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ use crate::{
3131
use ra_db::ExternSourceId;
3232
use rustc_hash::{FxHashMap, FxHashSet};
3333

34+
fn create_watcher(workspaces: &[ProjectWorkspace], options: &Options) -> CheckWatcher {
35+
workspaces
36+
.iter()
37+
.find_map(|w| match w {
38+
ProjectWorkspace::Cargo { cargo, .. } => Some(cargo),
39+
ProjectWorkspace::Json { .. } => None,
40+
})
41+
.map(|cargo| {
42+
let cargo_project_root = cargo.workspace_root().to_path_buf();
43+
Some(CheckWatcher::new(&options.cargo_watch, cargo_project_root))
44+
})
45+
.unwrap_or_else(|| {
46+
log::warn!("Cargo check watching only supported for cargo workspaces, disabling");
47+
None
48+
})
49+
}
50+
3451
#[derive(Debug, Clone)]
3552
pub struct Options {
3653
pub publish_decorations: bool,
@@ -168,20 +185,7 @@ impl WorldState {
168185
change.set_crate_graph(crate_graph);
169186

170187
// FIXME: Figure out the multi-workspace situation
171-
let check_watcher = workspaces
172-
.iter()
173-
.find_map(|w| match w {
174-
ProjectWorkspace::Cargo { cargo, .. } => Some(cargo),
175-
ProjectWorkspace::Json { .. } => None,
176-
})
177-
.map(|cargo| {
178-
let cargo_project_root = cargo.workspace_root().to_path_buf();
179-
Some(CheckWatcher::new(&options.cargo_watch, cargo_project_root))
180-
})
181-
.unwrap_or_else(|| {
182-
log::warn!("Cargo check watching only supported for cargo workspaces, disabling");
183-
None
184-
});
188+
let check_watcher = create_watcher(&workspaces, &options);
185189

186190
let mut analysis_host = AnalysisHost::new(lru_capacity);
187191
analysis_host.apply_change(change);
@@ -207,6 +211,7 @@ impl WorldState {
207211
) {
208212
self.feature_flags = Arc::new(feature_flags);
209213
self.analysis_host.update_lru_capacity(lru_capacity);
214+
self.check_watcher = create_watcher(&self.workspaces, &options);
210215
self.options = options;
211216
}
212217

0 commit comments

Comments
 (0)