mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 09:48:10 +00:00
Slightly more robust cargo watcher root search
This commit is contained in:
parent
19eb7fa1db
commit
1d1eea217d
2 changed files with 16 additions and 4 deletions
|
@ -74,7 +74,7 @@ impl WorldState {
|
|||
lru_capacity: Option<usize>,
|
||||
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);
|
||||
|
|
|
@ -21,7 +21,7 @@ use crate::Result;
|
|||
pub struct CargoWorkspace {
|
||||
packages: Arena<Package, PackageData>,
|
||||
targets: Arena<Target, TargetData>,
|
||||
pub(crate) workspace_root: PathBuf,
|
||||
pub workspace_root: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
|
|
Loading…
Reference in a new issue