aboutsummaryrefslogtreecommitdiff
path: root/crates/vfs/src/file_set.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/vfs/src/file_set.rs')
-rw-r--r--crates/vfs/src/file_set.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs
index 3f49f31e5..956cffb29 100644
--- a/crates/vfs/src/file_set.rs
+++ b/crates/vfs/src/file_set.rs
@@ -34,22 +34,27 @@ impl FileSet {
34 &self, 34 &self,
35 anchor: FileId, 35 anchor: FileId,
36 anchor_relative_path: Option<&str>, 36 anchor_relative_path: Option<&str>,
37 ) -> Option<Vec<(FileId, String)>> { 37 ) -> Option<Vec<FileId>> {
38 let anchor_directory = { 38 let anchor_directory = {
39 let path = self.paths[&anchor].clone(); 39 let path = self.paths[&anchor].clone();
40 match anchor_relative_path { 40 match anchor_relative_path {
41 Some(anchor_relative_path) => path.join(anchor_relative_path), 41 Some(anchor_relative_path) => path.join(anchor_relative_path),
42 None => path.join("../"), 42 None => path.parent(),
43 } 43 }
44 }?; 44 }?;
45 45
46 Some( 46 Some(
47 self.paths 47 self.paths
48 .iter() 48 .iter()
49 .filter(|(_, path)| path.starts_with(&anchor_directory)) 49 .filter_map(|(&file_id, path)| {
50 // TODO kb need to ensure that no / exists after the anchor_directory 50 if path.parent()? == anchor_directory
51 .filter(|(_, path)| path.ends_with(".rs")) 51 && matches!(path.file_name_and_extension(), Some((_, Some("rs"))))
52 .map(|(&file_id, path)| (file_id, path.to_string())) 52 {
53 Some(file_id)
54 } else {
55 None
56 }
57 })
53 .collect(), 58 .collect(),
54 ) 59 )
55 } 60 }