diff options
author | Kirill Bulatov <[email protected]> | 2020-09-04 00:25:00 +0100 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-09-09 23:42:20 +0100 |
commit | 8aa740dab46f138cacdf6391d46c87d6df810161 (patch) | |
tree | 09e2067cc9480dd500fdd648123ae9076ae0d4d8 /crates/vfs/src/file_set.rs | |
parent | 0de71f7bc9482c9d1ef7e9d36ec5d6c5fd378781 (diff) |
Happy path implemented
Diffstat (limited to 'crates/vfs/src/file_set.rs')
-rw-r--r-- | crates/vfs/src/file_set.rs | 17 |
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 | } |