diff options
Diffstat (limited to 'crates/vfs/src/file_set.rs')
-rw-r--r-- | crates/vfs/src/file_set.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs index 724606a3d..0173f7464 100644 --- a/crates/vfs/src/file_set.rs +++ b/crates/vfs/src/file_set.rs | |||
@@ -4,7 +4,6 @@ | |||
4 | //! the default `FileSet`. | 4 | //! the default `FileSet`. |
5 | use std::{fmt, iter}; | 5 | use std::{fmt, iter}; |
6 | 6 | ||
7 | use paths::AbsPathBuf; | ||
8 | use rustc_hash::FxHashMap; | 7 | use rustc_hash::FxHashMap; |
9 | 8 | ||
10 | use crate::{FileId, Vfs, VfsPath}; | 9 | use crate::{FileId, Vfs, VfsPath}; |
@@ -41,7 +40,7 @@ impl fmt::Debug for FileSet { | |||
41 | #[derive(Debug)] | 40 | #[derive(Debug)] |
42 | pub struct FileSetConfig { | 41 | pub struct FileSetConfig { |
43 | n_file_sets: usize, | 42 | n_file_sets: usize, |
44 | roots: Vec<(AbsPathBuf, usize)>, | 43 | roots: Vec<(VfsPath, usize)>, |
45 | } | 44 | } |
46 | 45 | ||
47 | impl Default for FileSetConfig { | 46 | impl Default for FileSetConfig { |
@@ -66,11 +65,7 @@ impl FileSetConfig { | |||
66 | self.n_file_sets | 65 | self.n_file_sets |
67 | } | 66 | } |
68 | fn classify(&self, path: &VfsPath) -> usize { | 67 | fn classify(&self, path: &VfsPath) -> usize { |
69 | let path = match path.as_path() { | 68 | let idx = match self.roots.binary_search_by(|(p, _)| p.cmp(path)) { |
70 | Some(it) => it, | ||
71 | None => return self.len() - 1, | ||
72 | }; | ||
73 | let idx = match self.roots.binary_search_by(|(p, _)| p.as_path().cmp(path)) { | ||
74 | Ok(it) => it, | 69 | Ok(it) => it, |
75 | Err(it) => it.saturating_sub(1), | 70 | Err(it) => it.saturating_sub(1), |
76 | }; | 71 | }; |
@@ -83,7 +78,7 @@ impl FileSetConfig { | |||
83 | } | 78 | } |
84 | 79 | ||
85 | pub struct FileSetConfigBuilder { | 80 | pub struct FileSetConfigBuilder { |
86 | roots: Vec<Vec<AbsPathBuf>>, | 81 | roots: Vec<Vec<VfsPath>>, |
87 | } | 82 | } |
88 | 83 | ||
89 | impl Default for FileSetConfigBuilder { | 84 | impl Default for FileSetConfigBuilder { |
@@ -96,12 +91,12 @@ impl FileSetConfigBuilder { | |||
96 | pub fn len(&self) -> usize { | 91 | pub fn len(&self) -> usize { |
97 | self.roots.len() | 92 | self.roots.len() |
98 | } | 93 | } |
99 | pub fn add_file_set(&mut self, roots: Vec<AbsPathBuf>) { | 94 | pub fn add_file_set(&mut self, roots: Vec<VfsPath>) { |
100 | self.roots.push(roots) | 95 | self.roots.push(roots) |
101 | } | 96 | } |
102 | pub fn build(self) -> FileSetConfig { | 97 | pub fn build(self) -> FileSetConfig { |
103 | let n_file_sets = self.roots.len() + 1; | 98 | let n_file_sets = self.roots.len() + 1; |
104 | let mut roots: Vec<(AbsPathBuf, usize)> = self | 99 | let mut roots: Vec<(VfsPath, usize)> = self |
105 | .roots | 100 | .roots |
106 | .into_iter() | 101 | .into_iter() |
107 | .enumerate() | 102 | .enumerate() |