Merge pull request #1223 from zed-industries/update-metadata-when-worktrees-are-removed

Update project metadata when releasing a worktree's weak handle
This commit is contained in:
Antonio Scandurra
2022-06-22 10:50:44 +02:00
committed by GitHub

View File

@@ -4088,16 +4088,17 @@ impl Project {
self.worktrees
.push(WorktreeHandle::Strong(worktree.clone()));
} else {
cx.observe_release(&worktree, |this, _, cx| {
this.worktrees
.retain(|worktree| worktree.upgrade(cx).is_some());
cx.notify();
})
.detach();
self.worktrees
.push(WorktreeHandle::Weak(worktree.downgrade()));
}
self.metadata_changed(true, cx);
cx.observe_release(&worktree, |this, worktree, cx| {
this.remove_worktree(worktree.id(), cx);
cx.notify();
})
.detach();
cx.emit(Event::WorktreeAdded);
cx.notify();
}