diff --git a/helix-term/src/ui/file_explorer.rs b/helix-term/src/ui/file_explorer.rs index 19eb1c088..34a0a896c 100644 --- a/helix-term/src/ui/file_explorer.rs +++ b/helix-term/src/ui/file_explorer.rs @@ -55,10 +55,8 @@ where return; }; - match overwrite(cx, picker_root.clone(), &overwrite_with) { - Some(Ok(msg)) => cx.editor.set_status(msg), - Some(Err(msg)) => cx.editor.set_error(msg), - None => (), + if let Some(result) = overwrite(cx, picker_root.clone(), &overwrite_with) { + cx.editor.set_result(result); }; }, ); @@ -99,10 +97,10 @@ fn create_file_operation_prompt( return; }; - match file_op(cx, &path, input.to_owned()) { - Some(Ok(msg)) => cx.editor.set_status(msg), - Some(Err(msg)) => cx.editor.set_error(msg), - None => cx.editor.clear_status(), + if let Some(result) = file_op(cx, &path, input.to_owned()) { + cx.editor.set_result(result); + } else { + cx.editor.clear_status(); }; }, ) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 739dcfb49..d79edf781 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -1299,6 +1299,14 @@ impl Editor { self.status_msg = Some((error, Severity::Error)); } + #[inline] + pub fn set_result>>(&mut self, result: Result) { + match result { + Ok(ok) => self.set_status(ok), + Err(err) => self.set_error(err), + } + } + #[inline] pub fn set_warning>>(&mut self, warning: T) { let warning = warning.into();