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_project_model/src/cargo_workspace.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_project_model') diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index 1b3c246c7..18c2f11b7 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs @@ -21,7 +21,7 @@ use crate::Result; pub struct CargoWorkspace { packages: Arena, targets: Arena, - pub(crate) workspace_root: PathBuf, + pub workspace_root: PathBuf, } #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] -- cgit v1.2.3 From d6da18e99d2fb4e67e3bc7503059282b5e14bd13 Mon Sep 17 00:00:00 2001 From: Emil Lauridsen Date: Fri, 10 Jan 2020 22:41:52 +0100 Subject: Address nit --- crates/ra_project_model/src/cargo_workspace.rs | 6 +++++- crates/ra_project_model/src/lib.rs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'crates/ra_project_model') diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index 18c2f11b7..1832c101f 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs @@ -21,7 +21,7 @@ use crate::Result; pub struct CargoWorkspace { packages: Arena, targets: Arena, - pub workspace_root: PathBuf, + workspace_root: PathBuf, } #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] @@ -225,4 +225,8 @@ impl CargoWorkspace { pub fn target_by_root(&self, root: &Path) -> Option { self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next() } + + pub fn workspace_root(&self) -> &Path { + &self.workspace_root + } } diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index b7f6a9b57..6a104e6f2 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs @@ -333,7 +333,7 @@ impl ProjectWorkspace { pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> { match self { ProjectWorkspace::Cargo { cargo, .. } => { - Some(cargo.workspace_root.as_ref()).filter(|root| path.starts_with(root)) + Some(cargo.workspace_root()).filter(|root| path.starts_with(root)) } ProjectWorkspace::Json { project: JsonProject { roots, .. } } => roots .iter() -- cgit v1.2.3