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.

Get language2 tests passing by not blocking on a foreground task

Nathan Sobo57dfc5068760
diff --git a/crates/gpui2/src/app/test_context.rs b/crates/gpui2/src/app/test_context.rs
index d7bf2b7087a..6affabdd238 100644
--- a/crates/gpui2/src/app/test_context.rs
+++ b/crates/gpui2/src/app/test_context.rs
@@ -4,7 +4,7 @@ use crate::{
WindowContext,
};
use anyhow::{anyhow, bail};
-use futures::{SinkExt, Stream, StreamExt};
+use futures::{Stream, StreamExt};
use std::{cell::RefCell, future::Future, rc::Rc, sync::Arc, time::Duration};
#[derive(Clone)]
@@ -165,13 +165,11 @@ impl TestAppContext {
where
T::Event: 'static + Clone,
{
- let (mut tx, rx) = futures::channel::mpsc::unbounded();
+ let (tx, rx) = futures::channel::mpsc::unbounded();
entity
.update(self, |_, cx: &mut ModelContext<T>| {
- cx.subscribe(entity, move |_, _, event, cx| {
- cx.background_executor()
- .block(tx.send(event.clone()))
- .unwrap();
+ cx.subscribe(entity, move |_model, _handle, event, _cx| {
+ let _ = tx.unbounded_send(event.clone());
})
})
.detach();
diff --git a/crates/gpui2_macros/src/derive_component.rs b/crates/gpui2_macros/src/derive_component.rs
index b5887e56208..d1919c8bc4f 100644
--- a/crates/gpui2_macros/src/derive_component.rs
+++ b/crates/gpui2_macros/src/derive_component.rs
@@ -36,10 +36,6 @@ pub fn derive_component(input: TokenStream) -> TokenStream {
}
};
- if name == "CollabPanel" {
- println!("{}", expanded)
- }
-
TokenStream::from(expanded)
}
diff --git a/crates/language2/src/buffer.rs b/crates/language2/src/buffer.rs
index d8e01494607..3999f275f2a 100644
--- a/crates/language2/src/buffer.rs
+++ b/crates/language2/src/buffer.rs
@@ -434,7 +434,7 @@ impl Buffer {
));
let text_operations = self.text.operations().clone();
- cx.spawn(|_| async move {
+ cx.background_executor().spawn(async move {
let since = since.unwrap_or_default();
operations.extend(
text_operations
diff --git a/crates/language2/src/buffer_tests.rs b/crates/language2/src/buffer_tests.rs
index 20125098789..16306fe2ce6 100644
--- a/crates/language2/src/buffer_tests.rs
+++ b/crates/language2/src/buffer_tests.rs
@@ -1943,6 +1943,7 @@ fn test_random_collaboration(cx: &mut AppContext, mut rng: StdRng) {
.detach();
buffer
});
+
buffers.push(buffer);
replica_ids.push(i as ReplicaId);
network.lock().add_peer(i as ReplicaId);