mirror of
https://github.com/zed-industries/zed.git
synced 2026-05-23 12:37:09 +00:00
Closes #48032 When restoring a diff hunk, we first unstage it unconditionally. That unstaging operation is a no-op in terms of the index text if the hunk was already not staged, but previously we would still always do `spawn_set_index_text_job` and bump the `hunk_staging_operation_count_as_of_write`. Bumping that count in turn causes us to skip a diff recalculation in response to the change in the buffer's text. That works out fine in the local case, because when the worktree picks up the write to `.git/index` we kick off another diff recalculation which is not skipped. But in the remote case, we don't get an `UpdateDiffBases` proto message if the index text didn't actually change, so there is no subsequent diff calculation to do the cleanup, and we end up with a stale no-op hunk. This PR fixes the issue by skipping the write to the index and the `hunk_staging_operation_count_as_of_write` bump if the new and old index texts are the same. 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 is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #ISSUE Release Notes: - Fixed a bug where restoring diff hunks in remote projects would leave stale no-op hunks in the UI. |
||
|---|---|---|
| .. | ||
| src | ||
| build.rs | ||
| Cargo.toml | ||
| LICENSE-GPL | ||