From fa83d3c4140778ccd153e353cc0fee2aa15498a6 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Fri, 23 Aug 2024 15:10:01 -0700 Subject: [PATCH] Include buildfile path in watcher list --- crates/rust-analyzer/src/reload.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 5d0c6b65992c..8a28de10e820 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -564,6 +564,23 @@ impl GlobalState { .collect() }; + // Also explicitly watch any build files configured in JSON project files. + for ws in self.workspaces.iter() { + if let ProjectWorkspaceKind::Json(project_json) = &ws.kind { + for (_, krate) in project_json.crates() { + let Some(build) = &krate.build else { + continue; + }; + watchers.push(lsp_types::FileSystemWatcher { + glob_pattern: lsp_types::GlobPattern::String( + build.build_file.to_string(), + ), + kind: None, + }); + } + } + } + watchers.extend( iter::once(Config::user_config_path()) .chain(self.workspaces.iter().map(|ws| ws.manifest().map(ManifestPath::as_ref)))