aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/libanalysis/tests/tests.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/crates/libanalysis/tests/tests.rs b/crates/libanalysis/tests/tests.rs
index 4fae7c313..9d2db731b 100644
--- a/crates/libanalysis/tests/tests.rs
+++ b/crates/libanalysis/tests/tests.rs
@@ -28,11 +28,18 @@ impl FileResolver for FileMap {
28 self.path(id).file_stem().unwrap().to_str().unwrap().to_string() 28 self.path(id).file_stem().unwrap().to_str().unwrap().to_string()
29 } 29 }
30 fn resolve(&self, id: FileId, rel: &RelativePath) -> Option<FileId> { 30 fn resolve(&self, id: FileId, rel: &RelativePath) -> Option<FileId> {
31 let path = rel.to_path(self.path(id)); 31 let path = {
32 let path = path.to_str().unwrap(); 32 if rel.starts_with("..") {
33 let path = RelativePath::new(&path[1..]).normalize(); 33 rel.strip_prefix("..").unwrap()
34 .to_path(&self.path(id).parent().unwrap())
35 } else {
36 rel.to_path(self.path(id))
37 }
38 };
39 let path = &path.to_str().unwrap()[1..];
40 let path = RelativePath::new(&path[0..]).normalize();
34 let &(id, _) = self.0.iter() 41 let &(id, _) = self.0.iter()
35 .find(|it| path == RelativePath::new(&it.1[1..]).normalize())?; 42 .find(|it| path == RelativePath::new(&it.1[0..]).normalize())?;
36 Some(FileId(id)) 43 Some(FileId(id))
37 } 44 }
38} 45}