diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 2b4e1847ef83c..1f88079eb27d2 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1160,10 +1160,10 @@ fn goto_file_impl(cx: &mut Context, action: Action) { let (view, doc) = current_ref!(cx.editor); let text = doc.text(); let selections = doc.selection(view.id); - let rel_path = match doc.relative_path() { - Some(p) => p.parent().unwrap().to_path_buf(), - _ => Path::new("").to_path_buf(), - }; + let rel_path = doc + .relative_path() + .map(|path| path.parent().unwrap().to_path_buf()) + .unwrap_or_default(); let mut paths: Vec<_> = selections .iter() .map(|r| text.slice(r.from()..r.to()).to_string())