fix: When calculating relative path, expand tilde last

pull/416/head
Blaž Hrastnik 3 years ago
parent cb4bab8903
commit b72c6204e5

@ -1049,14 +1049,12 @@ impl Document {
let cwdir = std::env::current_dir().expect("couldn't determine current directory"); let cwdir = std::env::current_dir().expect("couldn't determine current directory");
self.path.as_ref().map(|path| { self.path.as_ref().map(|path| {
let path = fold_home_dir(path); let path = if path.is_relative() {
if path.is_relative() { path.as_path()
path
} else { } else {
path.strip_prefix(cwdir) path.strip_prefix(cwdir).unwrap_or(path.as_path())
.map(|p| p.to_path_buf()) };
.unwrap_or(path) fold_home_dir(path)
}
}) })
} }

Loading…
Cancel
Save