diff options
author | Blaž Hrastnik | 2021-07-05 01:26:51 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-07-05 01:26:51 +0000 |
commit | 48481db8ca3a19c704825adb72a667c4266e9370 (patch) | |
tree | ca4f1a4b4107124f634f6d0142e0740af4a4ece5 /helix-view | |
parent | b72c6204e530987d825acb8b27667085b1c95158 (diff) |
fix: Make path absolute before normalizing
:open ../file.txt failed before because .. would be stripped
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/document.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index fdb6f8c3..2ab1602e 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -70,7 +70,6 @@ pub enum IndentStyle { } pub struct Document { - // rope + selection pub(crate) id: DocumentId, text: Rope, pub(crate) selections: HashMap<ViewId, Selection>, @@ -408,12 +407,13 @@ pub fn normalize_path(path: &Path) -> PathBuf { /// This function is used instead of `std::fs::canonicalize` because we don't want to verify /// here if the path exists, just normalize it's components. pub fn canonicalize_path(path: &Path) -> std::io::Result<PathBuf> { - let normalized = normalize_path(path); - if normalized.is_absolute() { - Ok(normalized) + let path = if path.is_relative() { + std::env::current_dir().map(|current_dir| current_dir.join(path))? } else { - std::env::current_dir().map(|current_dir| current_dir.join(normalized)) - } + path.to_path_buf() + }; + + Ok(normalize_path(&path)) } use helix_lsp::lsp; |