diff options
| author | bors <bors@rust-lang.org> | 2024-08-24 06:22:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-08-24 06:22:07 +0000 |
| commit | a074e1abbb7094fe1c744c2b733868dfe661fedc (patch) | |
| tree | 8ae25d3eecd351b9ed8be677f3684558405048a7 | |
| parent | 3bd42d3c4d9b97f2ef26d27ea8dd5aa6d52bcb16 (diff) | |
| parent | bdbc057becb15199813051e623b786f57a1d7466 (diff) | |
| download | rust-a074e1abbb7094fe1c744c2b733868dfe661fedc.tar.gz rust-a074e1abbb7094fe1c744c2b733868dfe661fedc.zip | |
Auto merge of #17949 - Wilfred:include_build_file_in_watchers, r=lnicola
fix: rust-analyzer should watch build files from rust-project.json rust-analyzer always watches Cargo.toml for changes, but other build systems using rust-project.json have their own build files. Ensure we also watch those for changes, so we know when to reconfigure rust-analyzer when dependencies change.
| -rw-r--r-- | src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs index 5d0c6b65992..8a28de10e82 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs +++ b/src/tools/rust-analyzer/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))) |
