diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 0461db4bf7..5485acb008 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -743,10 +743,31 @@ impl Worktree { Worktree::Local(this) => this.delete_entry(entry_id, trash, cx), Worktree::Remote(this) => this.delete_entry(entry_id, trash, cx), }?; - cx.emit(Event::DeletedEntry(entry_id)); + + let entry = match self { + Worktree::Local(ref this) => this.entry_for_id(entry_id), + Worktree::Remote(ref this) => this.entry_for_id(entry_id), + }?; + + let mut ids = vec![entry_id]; + let path = &*entry.path; + + self.get_children_ids_recursive(path, &mut ids); + + for id in ids { + cx.emit(Event::DeletedEntry(id)); + } Some(task) } + fn get_children_ids_recursive(&self, path: &Path, ids: &mut Vec) { + let children_iter = self.child_entries(path); + for child in children_iter { + ids.push(child.id); + self.get_children_ids_recursive(&child.path, ids); + } + } + pub fn rename_entry( &mut self, entry_id: ProjectEntryId,