# Save buffers after restoring hunks in the project diff \(\#25620\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/7a34dd98889f9863930319d622bfbb2496efe2c7)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 7a34dd98889f9863930319d622bfbb2496efe2c7

Requested commit: 7a34dd98889f9863930319d622bfbb2496efe2c7

Commit: 7a34dd98889f9863930319d622bfbb2496efe2c7

Tree: d2f37cb4f6f67e870fead72715e9362450630ba8

Author: Cole Miller

Committer: GitHub

## Message

```
Save buffers after restoring hunks in the project diff (#25620)

This PR fixes a bug where using the project diff editor to restore hunks
from a file that's not open in its own buffer would cause those reverts
to be lost once the project diff drops its excerpts for that file.

The fix is to save the buffers after restoring them but before the
excerpts are (potentially) dropped. This is done for the project diff
editor only. If we fail to save the affected files, we add their buffers
to the active workspace, so that the reverted contents are preserved and
the user can try again to save them.

- [x] Get it working
- [x] Test
- [ ] ~~Clean up boolean soup~~

Co-authored-by: Max <max@zed.dev>

Release Notes:

- N/A
```

## Parents

- [add7ae8052742cb5e205edfaf708dc652939badd](https://git.cafe/gitcafe/zed/commit/add7ae8052742cb5e205edfaf708dc652939badd?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/7a34dd98889f9863930319d622bfbb2496efe2c7?format=markdown)
