mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-29 21:49:33 +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| {
|
self.worktrees.retain(|worktree| {
|
||||||
worktree
|
if let Some(worktree) = worktree.upgrade(cx) {
|
||||||
.upgrade(cx)
|
let id = worktree.read(cx).id();
|
||||||
.map_or(false, |w| w.read(cx).id() != id)
|
if id == id_to_remove {
|
||||||
|
cx.emit(Event::WorktreeRemoved(id));
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
});
|
});
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue