From f1fc0bde993e7d4a8b806fdf7c7c50b1b09c5fd8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 21 Jan 2022 17:43:24 -0800 Subject: [PATCH] Flush effects after every spawned future completes Co-Authored-By: Nathan Sobo --- crates/gpui/src/app.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index b35eda41fa..11a8760700 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -1653,8 +1653,13 @@ impl MutableAppContext { Fut: 'static + Future, T: 'static, { + let future = f(self.to_async()); let cx = self.to_async(); - self.foreground.spawn(f(cx)) + self.foreground.spawn(async move { + let result = future.await; + cx.0.borrow_mut().flush_effects(); + result + }) } pub fn to_async(&self) -> AsyncAppContext {