editor: Fix split diff spacer calculation for non-row-aligned patch groups#53098
Merged
cole-miller merged 2 commits intozed-industries:mainfrom Apr 27, 2026
Merged
Conversation
Member
|
Thanks @timvermeulen! |
tomhoule
pushed a commit
that referenced
this pull request
Apr 27, 2026
…roups (#53098) Fixes a bug in the split diff spacer calculation when a patch group starts mid-row, sometimes causing extra spacers to be inserted. `spacer_blocks` already explicitly handles the case where `first_point` isn't at the start of `edit_for_first_point.old`, but the `while let Some(source_point) = source_points.next()` loop that follows implicitly assumes that `source_point` is at the start of `current_range`, which in turn seems to be based on the assumption that `current_range` starts at the beginning of a row. As it turns out, `current_range` isn't guaranteed to start at the beginning of a row, which can sometimes lead to incorrect spacer blocks being inserted. This addresses that by moving the existing `if edit_for_first_point.old.start < first_point` logic into the loop body as `if current_edit.old.start < current_boundary` in order to handle any non-row-aligned patch groups, not just the first one. Here's an example of how this bug could manifest: https://github.com/user-attachments/assets/1d3a5b4c-e4ad-4d87-804b-c4390d25f408 After: https://github.com/user-attachments/assets/b15acc62-33fe-4154-82e5-5cdf1806ffa7 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 Release Notes: - Fixed incorrect spacer blocks sometimes appearing in the split diff view when editing the file.
Member
|
@zed-industries/approved |
ebaah46
pushed a commit
to ebaah46/zed
that referenced
this pull request
May 6, 2026
…roups (zed-industries#53098) Fixes a bug in the split diff spacer calculation when a patch group starts mid-row, sometimes causing extra spacers to be inserted. `spacer_blocks` already explicitly handles the case where `first_point` isn't at the start of `edit_for_first_point.old`, but the `while let Some(source_point) = source_points.next()` loop that follows implicitly assumes that `source_point` is at the start of `current_range`, which in turn seems to be based on the assumption that `current_range` starts at the beginning of a row. As it turns out, `current_range` isn't guaranteed to start at the beginning of a row, which can sometimes lead to incorrect spacer blocks being inserted. This addresses that by moving the existing `if edit_for_first_point.old.start < first_point` logic into the loop body as `if current_edit.old.start < current_boundary` in order to handle any non-row-aligned patch groups, not just the first one. Here's an example of how this bug could manifest: https://github.com/user-attachments/assets/1d3a5b4c-e4ad-4d87-804b-c4390d25f408 After: https://github.com/user-attachments/assets/b15acc62-33fe-4154-82e5-5cdf1806ffa7 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 Release Notes: - Fixed incorrect spacer blocks sometimes appearing in the split diff view when editing the file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a bug in the split diff spacer calculation when a patch group starts mid-row, sometimes causing extra spacers to be inserted.
spacer_blocksalready explicitly handles the case wherefirst_pointisn't at the start ofedit_for_first_point.old, but thewhile let Some(source_point) = source_points.next()loop that follows implicitly assumes thatsource_pointis at the start ofcurrent_range, which in turn seems to be based on the assumption thatcurrent_rangestarts at the beginning of a row. As it turns out,current_rangeisn't guaranteed to start at the beginning of a row, which can sometimes lead to incorrect spacer blocks being inserted.This addresses that by moving the existing
if edit_for_first_point.old.start < first_pointlogic into the loop body asif current_edit.old.start < current_boundaryin order to handle any non-row-aligned patch groups, not just the first one.Here's an example of how this bug could manifest:
before.mov
After:
after.mov
Self-Review Checklist:
Release Notes: