diff options
Diffstat (limited to 'crates/vfs/src/vfs_path.rs')
-rw-r--r-- | crates/vfs/src/vfs_path.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/crates/vfs/src/vfs_path.rs b/crates/vfs/src/vfs_path.rs index f2d07038b..9a3690a89 100644 --- a/crates/vfs/src/vfs_path.rs +++ b/crates/vfs/src/vfs_path.rs | |||
@@ -48,10 +48,12 @@ impl VfsPath { | |||
48 | (VfsPathRepr::VirtualPath(_), _) => false, | 48 | (VfsPathRepr::VirtualPath(_), _) => false, |
49 | } | 49 | } |
50 | } | 50 | } |
51 | pub fn ends_with(&self, suffix: &str) -> bool { | 51 | pub fn parent(&self) -> Option<VfsPath> { |
52 | match &self.0 { | 52 | let mut parent = self.clone(); |
53 | VfsPathRepr::PathBuf(p) => p.ends_with(suffix), | 53 | if parent.pop() { |
54 | VfsPathRepr::VirtualPath(p) => p.ends_with(suffix), | 54 | Some(parent) |
55 | } else { | ||
56 | None | ||
55 | } | 57 | } |
56 | } | 58 | } |
57 | 59 | ||
@@ -265,9 +267,6 @@ impl VirtualPath { | |||
265 | fn starts_with(&self, other: &VirtualPath) -> bool { | 267 | fn starts_with(&self, other: &VirtualPath) -> bool { |
266 | self.0.starts_with(&other.0) | 268 | self.0.starts_with(&other.0) |
267 | } | 269 | } |
268 | fn ends_with(&self, suffix: &str) -> bool { | ||
269 | self.0.ends_with(suffix) | ||
270 | } | ||
271 | fn pop(&mut self) -> bool { | 270 | fn pop(&mut self) -> bool { |
272 | let pos = match self.0.rfind('/') { | 271 | let pos = match self.0.rfind('/') { |
273 | Some(pos) => pos, | 272 | Some(pos) => pos, |