summaryrefslogtreecommitdiff
path: root/helix-view/src/document.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r--helix-view/src/document.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 426c8e21..569e72ee 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -300,10 +300,11 @@ impl Document {
}
pub fn relative_path(&self) -> Option<&Path> {
- self.path.as_ref().map(|path| {
- path.strip_prefix(std::env::current_dir().unwrap())
- .unwrap_or(path)
- })
+ let cwdir = std::env::current_dir().expect("couldn't determine current directory");
+
+ self.path
+ .as_ref()
+ .map(|path| path.strip_prefix(cwdir).unwrap_or(path))
}
// pub fn slice<R>(&self, range: R) -> RopeSlice where R: RangeBounds {