mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-28 11:29:25 +00:00
Emit the WorktreeRemoved event when removing a worktree from a project
This commit is contained in:
parent
a1a4c70845
commit
e6be151a64
1 changed files with 12 additions and 4 deletions
|
@ -3603,11 +3603,19 @@ impl Project {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn remove_worktree(&mut self, id: WorktreeId, cx: &mut ModelContext<Self>) {
|
||||
pub fn remove_worktree(&mut self, id_to_remove: WorktreeId, cx: &mut ModelContext<Self>) {
|
||||
self.worktrees.retain(|worktree| {
|
||||
worktree
|
||||
.upgrade(cx)
|
||||
.map_or(false, |w| w.read(cx).id() != id)
|
||||
if let Some(worktree) = worktree.upgrade(cx) {
|
||||
let id = worktree.read(cx).id();
|
||||
if id == id_to_remove {
|
||||
cx.emit(Event::WorktreeRemoved(id));
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
});
|
||||
cx.notify();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue