Always store an rpc client on local worktrees

Even before sharing, we now want to advertise that the user is working
on a certain worktree, to make that visible to all of the worktree's
collaborators.
This commit is contained in:
Max Brunsfeld
2021-09-16 11:06:49 -07:00
parent 260114af6c
commit f0093974ee
4 changed files with 49 additions and 43 deletions
+3 -2
View File
@@ -546,10 +546,11 @@ impl Workspace {
cx: &mut ViewContext<Self>,
) -> Task<Result<ModelHandle<Worktree>>> {
let languages = self.languages.clone();
let rpc = self.rpc.clone();
let fs = self.fs.clone();
let path = Arc::from(path);
cx.spawn(|this, mut cx| async move {
let worktree = Worktree::open_local(path, languages, fs, &mut cx).await?;
let worktree = Worktree::open_local(rpc, path, fs, languages, &mut cx).await?;
this.update(&mut cx, |this, cx| {
cx.observe(&worktree, |_, _, cx| cx.notify()).detach();
this.worktrees.insert(worktree.clone());
@@ -826,7 +827,7 @@ impl Workspace {
let worktree = this.worktrees.iter().next()?;
worktree.update(cx, |worktree, cx| {
let worktree = worktree.as_local_mut()?;
Some(worktree.share(rpc, cx))
Some(worktree.share(cx))
})
});