mirror of https://github.com/helix-editor/helix
refactor: create Editor::set_result
parent
09021fdf30
commit
3aea7bba74
|
@ -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<F>(
|
|||
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();
|
||||
};
|
||||
},
|
||||
)
|
||||
|
|
|
@ -1299,6 +1299,14 @@ impl Editor {
|
|||
self.status_msg = Some((error, Severity::Error));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_result<T: Into<Cow<'static, str>>>(&mut self, result: Result<T, T>) {
|
||||
match result {
|
||||
Ok(ok) => self.set_status(ok),
|
||||
Err(err) => self.set_error(err),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_warning<T: Into<Cow<'static, str>>>(&mut self, warning: T) {
|
||||
let warning = warning.into();
|
||||
|
|
Loading…
Reference in New Issue