Flush effects when dropping a TestAppContext

Max Brunsfeld created

This way, at the end of a test, dropped entities will be removed, and will drop
the handles that they hold.

Change summary

crates/gpui/src/app.rs | 6 ++++++
1 file changed, 6 insertions(+)

Detailed changes

crates/gpui/src/app.rs 🔗

@@ -565,6 +565,12 @@ impl TestAppContext {
     }
 }
 
+impl Drop for TestAppContext {
+    fn drop(&mut self) {
+        self.cx.borrow_mut().flush_effects();
+    }
+}
+
 impl AsyncAppContext {
     pub fn spawn<F, Fut, T>(&self, f: F) -> Task<T>
     where