# project: Fix content swap when an LSP rename also renames the file \(\#59104\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 2243c13b9b224311fdb64362b2310c364f7dfbbb

Requested commit: 2243c13b9b224311fdb64362b2310c364f7dfbbb

Commit: 2243c13b9b224311fdb64362b2310c364f7dfbbb

Tree: 809e4a16021dcbddb17a75ecd1885aa52a795285

Author: Ibrahim Khan

Committer: GitHub

## Message

```
project: Fix content swap when an LSP rename also renames the file (#59104)

A "rename symbol" whose workspace edit also renames the file (a
`TextDocumentEdit` followed by a `RenameFile` resource operation) only
applied the text edit to the in-memory buffer. The on-disk file still
held the pre-edit content, so the blind `fs.rename` moved stale bytes to
the new path while the edited buffer was stranded at the old path,
swapping the two files' contents.

This persists a dirty buffer for the rename source before renaming, so
the new file receives the edited content and the now-clean buffer can't
be saved back to the old path.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #59077

Release Notes:

- Fixed a symbol rename that also renames the file swapping the contents
of the old and new files
```

## Parents

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

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