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",
"client2",
"clock",
"collab_ui",
"collab_ui2",
"collections",
"ctor",
"dashmap",

View file

@ -81,7 +81,7 @@ settings = { package = "settings2", path = "../settings2", features = ["test-sup
theme = { package = "theme2", path = "../theme2" }
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
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 fs::FakeFs;
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 node_runtime::FakeNodeRuntime;
@ -602,14 +602,12 @@ impl TestClient {
.unwrap()
}
//todo(workspace)
#[allow(dead_code)]
pub fn build_workspace(
&self,
pub fn build_workspace<'a>(
&'a self,
project: &Model<Project>,
cx: &mut TestAppContext,
) -> WindowHandle<Workspace> {
cx.add_window(|cx| Workspace::new(0, project.clone(), self.app_state.clone(), cx))
cx: &'a mut TestAppContext,
) -> (View<Workspace>, &'a mut VisualTestContext) {
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> {
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 {
Self { cx, window }
}

View file

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