project: Fix inability to open file after save as (#41012)

Update `project::buffer_store::BufferStore.save_buffer_as` in order to
correctly update the `path_to_buffer_id` hash map, ensuring that the
currently open file's path is dissociated from the buffer's id, to
prevent the new buffer from being open when trying to open the original
file.

Closes #29783 

Release Notes:

- Fixed issue where using `workspace: save as` would prevent users from
opening the original file from which the new file was created

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
This commit is contained in:
Dino
2025-10-24 15:27:34 +01:00
committed by GitHub
co-authored by Piotr Osiewicz
parent 762082b15a
commit 0ee6ca1767
2 changed files with 75 additions and 1 deletions
+8 -1
View File
@@ -909,7 +909,14 @@ impl BufferStore {
};
cx.spawn(async move |this, cx| {
task.await?;
this.update(cx, |_, cx| {
this.update(cx, |this, cx| {
old_file.clone().and_then(|file| {
this.path_to_buffer_id.remove(&ProjectPath {
worktree_id: file.worktree_id(cx),
path: file.path().clone(),
})
});
cx.emit(BufferStoreEvent::BufferChangedFilePath { buffer, old_file });
})
})