Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix logic for view to send on Follow (#8549)
Conrad Irwin6a3ac94eeadb
diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex f4ae96a05b5..07f69c3495b 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -2781,7 +2781,11 @@ impl Workspace {// RPC handlers- fn active_view_for_follower(&self, cx: &mut ViewContext<Self>) -> Option<proto::View> {+ fn active_view_for_follower(+ &self,+ follower_project_id: Option<u64>,+ cx: &mut ViewContext<Self>,+ ) -> Option<proto::View> {let item = self.active_item(cx)?;let leader_id = self.pane_for(&*item)@@ -2791,6 +2795,13 @@ impl Workspace {let id = item_handle.remote_id(&self.app_state.client, cx)?;let variant = item_handle.to_state_proto(cx)?;+ if item_handle.is_project_item(cx)+ && (follower_project_id.is_none()+ || follower_project_id != self.project.read(cx).remote_id())+ {+ return None;+ }+Some(proto::View {id: Some(id.to_proto()),leader_id,@@ -2806,7 +2817,7 @@ impl Workspace {let client = &self.app_state.client;let project_id = self.project.read(cx).remote_id();- let active_view = self.active_view_for_follower(cx);+ let active_view = self.active_view_for_follower(follower_project_id, cx);let active_view_id = active_view.as_ref().and_then(|view| view.id.clone());cx.notify();@@ -3981,7 +3992,6 @@ impl WorkspaceStore {project_id: envelope.payload.project_id,peer_id: envelope.original_sender_id()?,};- let active_project = ActiveCall::global(cx).read(cx).location().cloned();let mut response = proto::FollowResponse::default();this.workspaces.retain(|workspace| {@@ -3996,14 +4006,16 @@ impl WorkspaceStore {if let Some(active_view_id) = handler_response.active_view_id.clone() {if response.active_view_id.is_none()- || Some(workspace.project.downgrade()) == active_project+ || workspace.project.read(cx).remote_id() == follower.project_id{response.active_view_id = Some(active_view_id);}}if let Some(active_view) = handler_response.active_view.clone() {- if workspace.project.read(cx).remote_id() == follower.project_id {+ if response.active_view_id.is_none()+ || workspace.project.read(cx).remote_id() == follower.project_id+ {response.active_view = Some(active_view)}}