about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBernardo Uriarte <berublan@gmail.com>2022-05-21 16:18:55 +0200
committerBernardo Uriarte <berublan@gmail.com>2022-05-21 16:18:55 +0200
commit1ee8fefcff6d60652945c63c485ba55b5e2bf581 (patch)
treea7b1aadcd44d0ea1c8859abd5fe2f1b154b6590a
parent7009e5ab353dddcf9005c057e9af23d1c81d8a79 (diff)
downloadrust-1ee8fefcff6d60652945c63c485ba55b5e2bf581.tar.gz
rust-1ee8fefcff6d60652945c63c485ba55b5e2bf581.zip
take into account excludeDirs when computing linked_projects
-rw-r--r--crates/rust-analyzer/src/config.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index d7ae4c72f5c..d7e6c8a82ad 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -694,7 +694,22 @@ impl Config {
         match self.data.linkedProjects.as_slice() {
             [] => match self.discovered_projects.as_ref() {
                 Some(discovered_projects) => {
-                    discovered_projects.iter().cloned().map(LinkedProject::from).collect()
+                    let exclude_dirs: Vec<_> = self
+                        .data
+                        .files_excludeDirs
+                        .iter()
+                        .map(|p| self.root_path.join(p))
+                        .collect();
+                    discovered_projects
+                        .iter()
+                        .filter(|p| {
+                            let (ProjectManifest::ProjectJson(path)
+                            | ProjectManifest::CargoToml(path)) = p;
+                            !exclude_dirs.iter().any(|p| path.starts_with(p))
+                        })
+                        .cloned()
+                        .map(LinkedProject::from)
+                        .collect()
                 }
                 None => Vec::new(),
             },