diff --git a/zed/src/worktree.rs b/zed/src/worktree.rs index b7ac9d9eaf9cad842a5df64bcb4b16dd6513f329..e1d89c1cf6b8cef5414832bda8f7e2e58740bc38 100644 --- a/zed/src/worktree.rs +++ b/zed/src/worktree.rs @@ -172,6 +172,13 @@ impl Worktree { } } + pub fn replica_id(&self) -> ReplicaId { + match self { + Worktree::Local(_) => 0, + Worktree::Remote(worktree) => worktree.replica_id, + } + } + pub fn add_guest( &mut self, envelope: TypedEnvelope, @@ -194,6 +201,13 @@ impl Worktree { } } + pub fn peers(&self) -> &HashMap { + match self { + Worktree::Local(worktree) => &worktree.peers, + Worktree::Remote(worktree) => &worktree.peers, + } + } + pub fn open_buffer( &mut self, path: impl AsRef, @@ -464,6 +478,7 @@ impl LocalWorktree { .ok_or_else(|| anyhow!("empty peer"))?; self.peers .insert(PeerId(guest.peer_id), guest.replica_id as ReplicaId); + cx.notify(); Ok(()) } @@ -483,6 +498,7 @@ impl LocalWorktree { buffer.update(cx, |buffer, cx| buffer.remove_guest(replica_id, cx)); } } + cx.notify(); Ok(()) } @@ -910,6 +926,7 @@ impl RemoteWorktree { .ok_or_else(|| anyhow!("empty peer"))?; self.peers .insert(PeerId(guest.peer_id), guest.replica_id as ReplicaId); + cx.notify(); Ok(()) } @@ -928,6 +945,7 @@ impl RemoteWorktree { buffer.update(cx, |buffer, cx| buffer.remove_guest(replica_id, cx)); } } + cx.notify(); Ok(()) } }