@@ -2,7 +2,7 @@ use helix_view::Editor;
22
33use crate::compositor::Compositor;
44
5−use futures_util::future::{self, BoxFuture, Future, FutureExt};
5+use futures_util::future::{BoxFuture, Future, FutureExt};
66use futures_util::stream::{FuturesUnordered, StreamExt};
77
88pub type Callback = Box<dyn FnOnce(&mut Editor, &mut Compositor) + Send>;
@@ -93,9 +93,21 @@ impl Jobs {
9393 }
9494
9595 /// Blocks until all the jobs that need to be waited on are done.
96− pub async fn finish(&mut self) {
97− let wait_futures = std::mem::take(&mut self.wait_futures);
96+ pub async fn finish(&mut self) -> anyhow::Result<()> {
9897 log::debug!("waiting on jobs...");
99− wait_futures.for_each(|_| future::ready(())).await
98+ let mut wait_futures = std::mem::take(&mut self.wait_futures);
99+ while let (Some(job), tail) = wait_futures.into_future().await {
100+ match job {
101+ Ok(_) => {
102+ wait_futures = tail;
103+ }
104+ Err(e) => {
105+ self.wait_futures = tail;
106+ return Err(e);
107+ }
108+ }
109+ }
110+
111+ Ok(())
100112 }
101113}