mirror of https://github.com/helix-editor/helix
refactor: create Editor::set_result
parent
09021fdf30
commit
3aea7bba74
|
@ -55,10 +55,8 @@ where
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
match overwrite(cx, picker_root.clone(), &overwrite_with) {
|
if let Some(result) = overwrite(cx, picker_root.clone(), &overwrite_with) {
|
||||||
Some(Ok(msg)) => cx.editor.set_status(msg),
|
cx.editor.set_result(result);
|
||||||
Some(Err(msg)) => cx.editor.set_error(msg),
|
|
||||||
None => (),
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -99,10 +97,10 @@ fn create_file_operation_prompt<F>(
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
match file_op(cx, &path, input.to_owned()) {
|
if let Some(result) = file_op(cx, &path, input.to_owned()) {
|
||||||
Some(Ok(msg)) => cx.editor.set_status(msg),
|
cx.editor.set_result(result);
|
||||||
Some(Err(msg)) => cx.editor.set_error(msg),
|
} else {
|
||||||
None => cx.editor.clear_status(),
|
cx.editor.clear_status();
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -1299,6 +1299,14 @@ impl Editor {
|
||||||
self.status_msg = Some((error, Severity::Error));
|
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]
|
#[inline]
|
||||||
pub fn set_warning<T: Into<Cow<'static, str>>>(&mut self, warning: T) {
|
pub fn set_warning<T: Into<Cow<'static, str>>>(&mut self, warning: T) {
|
||||||
let warning = warning.into();
|
let warning = warning.into();
|
||||||
|
|
Loading…
Reference in New Issue