diff options
author | Blaž Hrastnik | 2021-02-22 03:06:28 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-02-22 03:06:28 +0000 |
commit | 8b9b02f08b5554a4c17e533937c74c1fb80df5f5 (patch) | |
tree | 06dfd723a47100fd1882c0a107e6984b0fde8b8b /helix-view/src/document.rs | |
parent | 3b6c9648f320d175de14e4b80df8980dcba54282 (diff) |
minor
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r-- | helix-view/src/document.rs | 9 |
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 { |