Don't use block_on in jobs.finish(), we can .await
commit6ea477ab60e242c2cd66af32ece601a691fcec4b
authorBlaž Hrastnik <blaz@mxxn.io>
dateSat 5 Feb 2022, 15:05 (5 years ago)
parentd3221b0
helix-term/src/application.rs+2−1
@@ -222,7 +222,6 @@ impl Application {
222222
223223 loop {
224224 if self.editor.should_close() {
225− self.jobs.finish();
226225 break;
227226 }
228227
@@ -666,6 +665,8 @@ impl Application {
666665
667666 self.event_loop().await;
668667
668+ self.jobs.finish().await;
669+
669670 if self.editor.close_language_servers(None).await.is_err() {
670671 log::error!("Timed out waiting for language servers to shutdown");
671672 };
helix-term/src/job.rs+2−2
@@ -93,8 +93,8 @@ impl Jobs {
9393 }
9494
9595 /// Blocks until all the jobs that need to be waited on are done.
96− pub fn finish(&mut self) {
96+ pub async fn finish(&mut self) {
9797 let wait_futures = std::mem::take(&mut self.wait_futures);
98− helix_lsp::block_on(wait_futures.for_each(|_| future::ready(())));
98+ wait_futures.for_each(|_| future::ready(())).await
9999 }
100100}