aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-01-11 20:41:41 +0000
committerGitHub <[email protected]>2020-01-11 20:41:41 +0000
commit3924c7de505b591d3e1281857a61713fbe308d59 (patch)
tree2bab7953c6fb1d089ce2acaf7b646adc4921b128 /crates/ra_project_model
parent867081220921c1c593f11866bbdba8b845090c07 (diff)
parent8e778f9842123e1f688a2632d99e439821801bd2 (diff)
Merge #2791
2791: Slightly more robust cargo watcher root search r=kiljacken a=kiljacken Fixes #2780 (hopefully). Use the already painstakingly found `workspaces` instead of naively using `folder_roots` from editor. Co-authored-by: Emil Lauridsen <[email protected]>
Diffstat (limited to 'crates/ra_project_model')
-rw-r--r--crates/ra_project_model/src/cargo_workspace.rs6
-rw-r--r--crates/ra_project_model/src/lib.rs2
2 files changed, 6 insertions, 2 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs
index 1b3c246c7..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;
21pub struct CargoWorkspace { 21pub struct CargoWorkspace {
22 packages: Arena<Package, PackageData>, 22 packages: Arena<Package, PackageData>,
23 targets: Arena<Target, TargetData>, 23 targets: Arena<Target, TargetData>,
24 pub(crate) workspace_root: PathBuf, 24 workspace_root: PathBuf,
25} 25}
26 26
27#[derive(Deserialize, Clone, Debug, PartialEq, Eq)] 27#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
@@ -225,4 +225,8 @@ impl CargoWorkspace {
225 pub fn target_by_root(&self, root: &Path) -> Option<Target> { 225 pub fn target_by_root(&self, root: &Path) -> Option<Target> {
226 self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next() 226 self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next()
227 } 227 }
228
229 pub fn workspace_root(&self) -> &Path {
230 &self.workspace_root
231 }
228} 232}
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 {
333 pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> { 333 pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> {
334 match self { 334 match self {
335 ProjectWorkspace::Cargo { cargo, .. } => { 335 ProjectWorkspace::Cargo { cargo, .. } => {
336 Some(cargo.workspace_root.as_ref()).filter(|root| path.starts_with(root)) 336 Some(cargo.workspace_root()).filter(|root| path.starts_with(root))
337 } 337 }
338 ProjectWorkspace::Json { project: JsonProject { roots, .. } } => roots 338 ProjectWorkspace::Json { project: JsonProject { roots, .. } } => roots
339 .iter() 339 .iter()