Skip to content

Commit

Permalink
fix: When calculating relative path, expand tilde last
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Jul 5, 2021
1 parent cb4bab8 commit b72c620
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

Expand Down

0 comments on commit b72c620

Please sign in to comment.