diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 7a826740f14072b0d221bc465013b770058ffbe0..d0cf2faa7eedb0dc76ab277fbf47ba67d3574815 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -1491,7 +1491,12 @@ impl LocalSnapshot { } let scan_id = self.scan_id; - self.entries_by_path.insert_or_replace(entry.clone(), &()); + let removed = self.entries_by_path.insert_or_replace(entry.clone(), &()); + if let Some(removed) = removed { + if removed.id != entry.id { + self.entries_by_id.remove(&removed.id, &()); + } + } self.entries_by_id.insert_or_replace( PathEntry { id: entry.id,