diff options
author | Blaž Hrastnik | 2021-07-05 01:17:26 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-07-05 01:17:26 +0000 |
commit | b72c6204e530987d825acb8b27667085b1c95158 (patch) | |
tree | 0852e964d89db6e9bc765fdd28f81b3a8ce52484 | |
parent | cb4bab890300c747afbd00c3290e6311bf72b0da (diff) |
fix: When calculating relative path, expand tilde last
-rw-r--r-- | helix-view/src/document.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index f85ded11..fdb6f8c3 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -1049,14 +1049,12 @@ impl Document { let cwdir = std::env::current_dir().expect("couldn't determine current directory"); self.path.as_ref().map(|path| { - let path = fold_home_dir(path); - if path.is_relative() { - path + let path = if path.is_relative() { + path.as_path() } else { - path.strip_prefix(cwdir) - .map(|p| p.to_path_buf()) - .unwrap_or(path) - } + path.strip_prefix(cwdir).unwrap_or(path.as_path()) + }; + fold_home_dir(path) }) } |