Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Ensure workspace gets rendered in collab integration tests
Antonio Scandurrac65465b0b5bb
diff --git a/crates/collab/src/tests.rs b/crates/collab/src/tests.rsindex 81a505cc4e7..64768d1a479 100644--- a/crates/collab/src/tests.rs+++ b/crates/collab/src/tests.rs@@ -12,7 +12,10 @@ use client::{use collections::{HashMap, HashSet};use fs::FakeFs;use futures::{channel::oneshot, StreamExt as _};-use gpui::{executor::Deterministic, test::EmptyView, ModelHandle, TestAppContext, ViewHandle};+use gpui::{+ elements::*, executor::Deterministic, AnyElement, Entity, ModelHandle, TestAppContext, View,+ ViewContext, ViewHandle, WeakViewHandle,+};use language::LanguageRegistry;use parking_lot::Mutex;use project::{Project, WorktreeId};@@ -462,8 +465,41 @@ impl TestClient {project: &ModelHandle<Project>,cx: &mut TestAppContext,) -> ViewHandle<Workspace> {- let (window_id, _) = cx.add_window(|_| EmptyView);- cx.add_view(window_id, |cx| Workspace::test_new(project.clone(), cx))+ struct WorkspaceContainer {+ workspace: Option<WeakViewHandle<Workspace>>,+ }++ impl Entity for WorkspaceContainer {+ type Event = ();+ }++ impl View for WorkspaceContainer {+ fn ui_name() -> &'static str {+ "WorkspaceContainer"+ }++ fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {+ if let Some(workspace) = self+ .workspace+ .as_ref()+ .and_then(|workspace| workspace.upgrade(cx))+ {+ ChildView::new(&workspace, cx).into_any()+ } else {+ Empty::new().into_any()+ }+ }+ }++ // We use a workspace container so that we don't need to remove the window in order to+ // drop the workspace and we can use a ViewHandle instead.+ let (window_id, container) = cx.add_window(|_| WorkspaceContainer { workspace: None });+ let workspace = cx.add_view(window_id, |cx| Workspace::test_new(project.clone(), cx));+ container.update(cx, |container, cx| {+ container.workspace = Some(workspace.downgrade());+ cx.notify();+ });+ workspace}}