aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/job.rs
diff options
context:
space:
mode:
authorSkyler Hawthorne2022-09-03 03:38:38 +0000
committerSkyler Hawthorne2022-10-19 02:31:39 +0000
commitb530a86d1f15cc7df0e1ae8aa4bd02109ac33a8f (patch)
treea2dce789418ecc463490a98ee90a4da3631a076f /helix-term/src/job.rs
parentb3fc31a211293f48696d26855781577d1859c2c6 (diff)
remove Callback::Compositor variant
To reduce likelihood of accidental discarding of important callbacks
Diffstat (limited to 'helix-term/src/job.rs')
-rw-r--r--helix-term/src/job.rs20
1 files changed, 4 insertions, 16 deletions
diff --git a/helix-term/src/job.rs b/helix-term/src/job.rs
index 3c9e4511..2888b6eb 100644
--- a/helix-term/src/job.rs
+++ b/helix-term/src/job.rs
@@ -8,7 +8,6 @@ use futures_util::stream::{FuturesUnordered, StreamExt};
pub enum Callback {
EditorCompositor(Box<dyn FnOnce(&mut Editor, &mut Compositor) + Send>),
Editor(Box<dyn FnOnce(&mut Editor) + Send>),
- Compositor(Box<dyn FnOnce(&mut Compositor) + Send>),
}
pub type JobFuture = BoxFuture<'static, anyhow::Result<Option<Callback>>>;
@@ -76,7 +75,6 @@ impl Jobs {
Ok(Some(call)) => match call {
Callback::EditorCompositor(call) => call(editor, compositor),
Callback::Editor(call) => call(editor),
- Callback::Compositor(call) => call(compositor),
},
Err(e) => {
editor.set_error(format!("Async job failed: {}", e));
@@ -102,7 +100,7 @@ impl Jobs {
/// Blocks until all the jobs that need to be waited on are done.
pub async fn finish(
&mut self,
- mut editor: Option<&mut Editor>,
+ editor: &mut Editor,
mut compositor: Option<&mut Compositor>,
) -> anyhow::Result<()> {
log::debug!("waiting on jobs...");
@@ -117,20 +115,10 @@ impl Jobs {
// clippy doesn't realize this is an error without the derefs
#[allow(clippy::needless_option_as_deref)]
match callback {
- Callback::EditorCompositor(call)
- if editor.is_some() && compositor.is_some() =>
- {
- call(
- editor.as_deref_mut().unwrap(),
- compositor.as_deref_mut().unwrap(),
- )
- }
- Callback::Editor(call) if editor.is_some() => {
- call(editor.as_deref_mut().unwrap())
- }
- Callback::Compositor(call) if compositor.is_some() => {
- call(compositor.as_deref_mut().unwrap())
+ Callback::EditorCompositor(call) if compositor.is_some() => {
+ call(editor, compositor.as_deref_mut().unwrap())
}
+ Callback::Editor(call) => call(editor),
// skip callbacks for which we don't have the necessary references
_ => (),