aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/job.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/job.rs')
-rw-r--r--helix-term/src/job.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/helix-term/src/job.rs b/helix-term/src/job.rs
index a6a77021..e5147992 100644
--- a/helix-term/src/job.rs
+++ b/helix-term/src/job.rs
@@ -2,7 +2,7 @@ use helix_view::Editor;
use crate::compositor::Compositor;
-use futures_util::future::{self, BoxFuture, Future, FutureExt};
+use futures_util::future::{BoxFuture, Future, FutureExt};
use futures_util::stream::{FuturesUnordered, StreamExt};
pub type Callback = Box<dyn FnOnce(&mut Editor, &mut Compositor) + Send>;
@@ -93,8 +93,21 @@ impl Jobs {
}
/// Blocks until all the jobs that need to be waited on are done.
- pub async fn finish(&mut self) {
- let wait_futures = std::mem::take(&mut self.wait_futures);
- wait_futures.for_each(|_| future::ready(())).await
+ pub async fn finish(&mut self) -> anyhow::Result<()> {
+ log::debug!("waiting on jobs...");
+ let mut wait_futures = std::mem::take(&mut self.wait_futures);
+ while let (Some(job), tail) = wait_futures.into_future().await {
+ match job {
+ Ok(_) => {
+ wait_futures = tail;
+ }
+ Err(e) => {
+ self.wait_futures = tail;
+ return Err(e);
+ }
+ }
+ }
+
+ Ok(())
}
}