mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-26 00:19:46 +00:00
Expose Worktree::{peers,replica_id}
This commit is contained in:
parent
ed9036f3fc
commit
e07065265d
1 changed files with 18 additions and 0 deletions
|
@ -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<proto::AddGuest>,
|
||||
|
@ -194,6 +201,13 @@ impl Worktree {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn peers(&self) -> &HashMap<PeerId, ReplicaId> {
|
||||
match self {
|
||||
Worktree::Local(worktree) => &worktree.peers,
|
||||
Worktree::Remote(worktree) => &worktree.peers,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn open_buffer(
|
||||
&mut self,
|
||||
path: impl AsRef<Path>,
|
||||
|
@ -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(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue