Fix staging and unstaging of added and deleted files (#25631)

* When staging in a buffer whose file has been deleted, do not save the
file
* Fix logic for writing to index when file is deleted

Release Notes:

- N/A
This commit is contained in:
Max Brunsfeld 2025-02-25 23:25:31 -08:00 committed by GitHub
parent 33754f8eac
commit ebccef1aa4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 88 additions and 48 deletions

View file

@ -1071,7 +1071,13 @@ impl Repository {
};
let project_path = (self.worktree_id, path).into();
if let Some(buffer) = buffer_store.get_by_path(&project_path, cx) {
save_futures.push(buffer_store.save_buffer(buffer, cx));
if buffer
.read(cx)
.file()
.map_or(false, |file| file.disk_state().exists())
{
save_futures.push(buffer_store.save_buffer(buffer, cx));
}
}
}
})
@ -1110,7 +1116,13 @@ impl Repository {
};
let project_path = (self.worktree_id, path).into();
if let Some(buffer) = buffer_store.get_by_path(&project_path, cx) {
save_futures.push(buffer_store.save_buffer(buffer, cx));
if buffer
.read(cx)
.file()
.map_or(false, |file| file.disk_state().exists())
{
save_futures.push(buffer_store.save_buffer(buffer, cx));
}
}
}
})