From 6ea477ab60e242c2cd66af32ece601a691fcec4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Sat, 5 Feb 2022 15:05:19 +0900 Subject: [PATCH] Don't use block_on in jobs.finish(), we can .await --- helix-term/src/application.rs | 3 ++- helix-term/src/job.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index ae154a24d..8f405ce5b 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -222,7 +222,6 @@ impl Application { loop { if self.editor.should_close() { - self.jobs.finish(); break; } @@ -666,6 +665,8 @@ impl Application { self.event_loop().await; + self.jobs.finish().await; + if self.editor.close_language_servers(None).await.is_err() { log::error!("Timed out waiting for language servers to shutdown"); }; diff --git a/helix-term/src/job.rs b/helix-term/src/job.rs index f5a0a425c..a6a770211 100644 --- a/helix-term/src/job.rs +++ b/helix-term/src/job.rs @@ -93,8 +93,8 @@ impl Jobs { } /// Blocks until all the jobs that need to be waited on are done. - pub fn finish(&mut self) { + pub async fn finish(&mut self) { let wait_futures = std::mem::take(&mut self.wait_futures); - helix_lsp::block_on(wait_futures.for_each(|_| future::ready(()))); + wait_futures.for_each(|_| future::ready(())).await } }