on master help sign in
Simplify set_path
commit3e69a4852eb9914ced7438c0788170c43756d741 authorBlaž Hrastnik <blaz@mxxn.io> dateThu 28 Oct 2021, 10:50 (5 years ago) parent0a38983
1 file changed+3−5
helix-view/src/document.rs+3−5
helix-view/src/document.rs+3−5
@@ -554,11 +554,9 @@ impl Document {
554554 }
555555
556556 pub fn set_path(&mut self, path: Option<&Path>) -> Result<(), std::io::Error> {
557− let path = if let Some(p) = path {
558− Some(helix_core::path::get_canonicalized_path(p)?)
559− } else {
560− path.map(|p| p.into())
561− };
557+ let path = path
558+ .map(|path| helix_core::path::get_canonicalized_path(path))
559+ .transpose()?;
562560
563561 // if parent doesn't exist we still want to open the document
564562 // and error out when document is saved