on master help sign in
fix: Make path absolute before normalizing
48481dbBlaž Hrastnik
helix-view/src/document.rs+6−6
@@ -70,7 +70,6 @@ pub enum IndentStyle {
70}
70}
71
71
72pub struct Document {
72pub struct Document {
73− // rope + selection
74 pub(crate) id: DocumentId,
73 pub(crate) id: DocumentId,
75 text: Rope,
74 text: Rope,
76 pub(crate) selections: HashMap<ViewId, Selection>,
75 pub(crate) selections: HashMap<ViewId, Selection>,
@@ -408,12 +407,13 @@ pub fn normalize_path(path: &Path) -> PathBuf {
408/// This function is used instead of `std::fs::canonicalize` because we don't want to verify
407/// This function is used instead of `std::fs::canonicalize` because we don't want to verify
409/// here if the path exists, just normalize it's components.
408/// here if the path exists, just normalize it's components.
410pub fn canonicalize_path(path: &Path) -> std::io::Result<PathBuf> {
409pub fn canonicalize_path(path: &Path) -> std::io::Result<PathBuf> {
411− let normalized = normalize_path(path);
410+ let path = if path.is_relative() {
412− if normalized.is_absolute() {
411+ std::env::current_dir().map(|current_dir| current_dir.join(path))?
413− Ok(normalized)
414 } else {
412 } else {
415− std::env::current_dir().map(|current_dir| current_dir.join(normalized))
413+ path.to_path_buf()
416− }
414+ };
415+
416+ Ok(normalize_path(&path))
417}
417}
418
418
419use helix_lsp::lsp;
419use helix_lsp::lsp;