Fix propagation of active item to followers

Enable channel buffer integration tests.
This commit is contained in:
Max Brunsfeld 2023-12-06 12:18:48 -08:00
parent e9dcca7712
commit 6bbb1642b8
6 changed files with 906 additions and 897 deletions

2
Cargo.lock generated
View file

@ -1830,7 +1830,7 @@ dependencies = [
"clap 3.2.25", "clap 3.2.25",
"client2", "client2",
"clock", "clock",
"collab_ui", "collab_ui2",
"collections", "collections",
"ctor", "ctor",
"dashmap", "dashmap",

View file

@ -81,7 +81,7 @@ settings = { package = "settings2", path = "../settings2", features = ["test-sup
theme = { package = "theme2", path = "../theme2" } theme = { package = "theme2", path = "../theme2" }
workspace = { package = "workspace2", path = "../workspace2", features = ["test-support"] } workspace = { package = "workspace2", path = "../workspace2", features = ["test-support"] }
collab_ui = { path = "../collab_ui", features = ["test-support"] } collab_ui = { path = "../collab_ui2", package = "collab_ui2", features = ["test-support"] }
async-trait.workspace = true async-trait.workspace = true
pretty_assertions.workspace = true pretty_assertions.workspace = true

File diff suppressed because it is too large Load diff

View file

@ -13,7 +13,7 @@ use client::{
use collections::{HashMap, HashSet}; use collections::{HashMap, HashSet};
use fs::FakeFs; use fs::FakeFs;
use futures::{channel::oneshot, StreamExt as _}; use futures::{channel::oneshot, StreamExt as _};
use gpui::{BackgroundExecutor, Context, Model, TestAppContext, WindowHandle}; use gpui::{BackgroundExecutor, Context, Model, TestAppContext, View, VisualTestContext};
use language::LanguageRegistry; use language::LanguageRegistry;
use node_runtime::FakeNodeRuntime; use node_runtime::FakeNodeRuntime;
@ -602,14 +602,12 @@ impl TestClient {
.unwrap() .unwrap()
} }
//todo(workspace) pub fn build_workspace<'a>(
#[allow(dead_code)] &'a self,
pub fn build_workspace(
&self,
project: &Model<Project>, project: &Model<Project>,
cx: &mut TestAppContext, cx: &'a mut TestAppContext,
) -> WindowHandle<Workspace> { ) -> (View<Workspace>, &'a mut VisualTestContext) {
cx.add_window(|cx| Workspace::new(0, project.clone(), self.app_state.clone(), cx)) cx.add_window_view(|cx| Workspace::new(0, project.clone(), self.app_state.clone(), cx))
} }
} }

View file

@ -545,6 +545,10 @@ pub struct VisualTestContext<'a> {
} }
impl<'a> VisualTestContext<'a> { impl<'a> VisualTestContext<'a> {
pub fn update<R>(&mut self, f: impl FnOnce(&mut WindowContext) -> R) -> R {
self.cx.update_window(self.window, |_, cx| f(cx)).unwrap()
}
pub fn from_window(window: AnyWindowHandle, cx: &'a mut TestAppContext) -> Self { pub fn from_window(window: AnyWindowHandle, cx: &'a mut TestAppContext) -> Self {
Self { cx, window } Self { cx, window }
} }

View file

@ -2077,6 +2077,7 @@ impl Workspace {
} }
if &pane == self.active_pane() { if &pane == self.active_pane() {
self.active_item_path_changed(cx); self.active_item_path_changed(cx);
self.update_active_view_for_followers(cx);
} }
} }
pane::Event::ChangeItemTitle => { pane::Event::ChangeItemTitle => {
@ -2756,18 +2757,18 @@ impl Workspace {
fn update_active_view_for_followers(&mut self, cx: &mut ViewContext<Self>) { fn update_active_view_for_followers(&mut self, cx: &mut ViewContext<Self>) {
let mut is_project_item = true; let mut is_project_item = true;
let mut update = proto::UpdateActiveView::default(); let mut update = proto::UpdateActiveView::default();
if self.active_pane.read(cx).has_focus(cx) {
let item = self if let Some(item) = self.active_item(cx) {
.active_item(cx) if item.focus_handle(cx).contains_focused(cx) {
.and_then(|item| item.to_followable_item_handle(cx)); if let Some(item) = item.to_followable_item_handle(cx) {
if let Some(item) = item { is_project_item = item.is_project_item(cx);
is_project_item = item.is_project_item(cx); update = proto::UpdateActiveView {
update = proto::UpdateActiveView { id: item
id: item .remote_id(&self.app_state.client, cx)
.remote_id(&self.app_state.client, cx) .map(|id| id.to_proto()),
.map(|id| id.to_proto()), leader_id: self.leader_for_pane(&self.active_pane),
leader_id: self.leader_for_pane(&self.active_pane), };
}; }
} }
} }