From 22f4f313f1cbdaadafcc3dd471f5a0bb4f7034e1 Mon Sep 17 00:00:00 2001 From: nkitsaini Date: Mon, 21 Aug 2023 00:41:32 +0530 Subject: Remove unnecessary `Err` from `get_canonicalized_path` (#8009) Co-authored-by: Michael Davis --- helix-view/src/document.rs | 12 ++++-------- helix-view/src/editor.rs | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'helix-view/src') diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 3477608b..08b57f21 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -708,7 +708,7 @@ impl Document { let mut doc = Self::from(rope, Some((encoding, has_bom)), config); // set the path and try detecting the language - doc.set_path(Some(path))?; + doc.set_path(Some(path)); if let Some(loader) = config_loader { doc.detect_language(loader); } @@ -853,7 +853,7 @@ impl Document { let text = self.text().clone(); let path = match path { - Some(path) => helix_core::path::get_canonicalized_path(&path)?, + Some(path) => helix_core::path::get_canonicalized_path(&path), None => { if self.path.is_none() { bail!("Can't save with no path set!"); @@ -1047,18 +1047,14 @@ impl Document { self.encoding } - pub fn set_path(&mut self, path: Option<&Path>) -> Result<(), std::io::Error> { - let path = path - .map(helix_core::path::get_canonicalized_path) - .transpose()?; + pub fn set_path(&mut self, path: Option<&Path>) { + let path = path.map(helix_core::path::get_canonicalized_path); // if parent doesn't exist we still want to open the document // and error out when document is saved self.path = path; self.detect_readonly(); - - Ok(()) } /// Set the programming language for the file and load associated data (e.g. highlighting) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 66542e89..1735b060 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -1436,7 +1436,7 @@ impl Editor { // ??? possible use for integration tests pub fn open(&mut self, path: &Path, action: Action) -> Result { - let path = helix_core::path::get_canonicalized_path(path)?; + let path = helix_core::path::get_canonicalized_path(path); let id = self.document_by_path(&path).map(|doc| doc.id); let id = if let Some(id) = id { -- cgit v1.2.3-70-g09d2