Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Don't run until all the way until parked when waiting for a model's next event

Max Brunsfeldf9650b3111f7
diff --git a/crates/gpui2/src/app/test_context.rs b/crates/gpui2/src/app/test_context.rs
index 5397a2214d4..37f81da15b9 100644
--- a/crates/gpui2/src/app/test_context.rs
+++ b/crates/gpui2/src/app/test_context.rs
@@ -354,10 +354,18 @@ impl<T: Send> Model<T> {
})
});
- cx.executor().run_until_parked();
- rx.try_next()
- .expect("no event received")
- .expect("model was dropped")
+ loop {
+ match rx.try_next() {
+ Ok(Some(event)) => return event,
+ Ok(None) => panic!("model was dropped"),
+ Err(_) => {
+ if !cx.executor().run_step() {
+ break;
+ }
+ }
+ }
+ }
+ panic!("no event received")
}
}