diff --git a/zed/src/worktree.rs b/zed/src/worktree.rs index d8e96560036ba887fdf8e680580d4e89dea36eb6..5911480404fd11677ef4c35b0b6ba488f1c4891e 100644 --- a/zed/src/worktree.rs +++ b/zed/src/worktree.rs @@ -53,10 +53,10 @@ lazy_static! { } pub fn init(cx: &mut MutableAppContext, rpc: rpc::Client) { + rpc.on_message(remote::remove_guest, cx); rpc.on_message(remote::open_buffer, cx); rpc.on_message(remote::close_buffer, cx); rpc.on_message(remote::update_buffer, cx); - rpc.on_message(remote::remove_guest, cx); } #[derive(Clone, Debug)] @@ -154,6 +154,17 @@ impl Worktree { } } + pub fn remove_guest( + &mut self, + envelope: TypedEnvelope, + cx: &mut ModelContext, + ) -> Result<()> { + match self { + Worktree::Local(worktree) => worktree.remove_guest(envelope, cx), + Worktree::Remote(_) => todo!(), + } + } + pub fn open_buffer( &mut self, path: impl AsRef, @@ -1926,7 +1937,18 @@ impl<'a> Iterator for ChildEntriesIter<'a> { mod remote { use super::*; - use crate::rpc::TypedEnvelope; + + pub async fn remove_guest( + envelope: TypedEnvelope, + rpc: &rpc::Client, + cx: &mut AsyncAppContext, + ) -> anyhow::Result<()> { + rpc.state + .lock() + .await + .shared_worktree(envelope.payload.worktree_id, cx)? + .update(cx, |worktree, cx| worktree.remove_guest(envelope, cx)) + } pub async fn open_buffer( envelope: TypedEnvelope, @@ -1992,21 +2014,6 @@ mod remote { Ok(()) } - - pub async fn remove_guest( - envelope: TypedEnvelope, - rpc: &rpc::Client, - cx: &mut AsyncAppContext, - ) -> anyhow::Result<()> { - rpc.state - .lock() - .await - .shared_worktree(envelope.payload.worktree_id, cx)? - .update(cx, |worktree, cx| match worktree { - Worktree::Local(worktree) => worktree.remove_guest(envelope, cx), - Worktree::Remote(_) => todo!(), - }) - } } #[cfg(test)]