Skip to content

fix(diff): keep finished boxes when the myers budget runs out - #56

Merged
seatedro merged 1 commit into
masterfrom
rohit/diff-core-myers-keep-finished
Nov 3, 2026
Merged

seatedro merged 1 commit into
masterfrom
rohit/diff-core-myers-keep-finished

Conversation

@seatedro

@seatedro seatedro commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Large, heavily edited files could get corrupt line diffs, with hunks past the end of the file (a panic in debug builds), because when the budgeted Myers search ran out of work it cleared the changes it had already found and never searched those parts again. It now keeps what it finished and splits only the parts it left.

When the budgeted search over the whole input ran out of work, solve
cleared every mark before splitting the boxes it had left. The boxes it
had already finished were marked for good and never searched again, so
their changes were lost: the two sides ended up with different counts
of unchanged items, and changes() emitted misaligned ranges, some past
the end of the old side. diff_texts then underflowed computing the
trailing gap.

Search::run only marks boxes it finishes, and the boxes it leaves are
unmarked and disjoint from them, so the clear was never needed. Drop
it, as Anchors::run already does for the regions it re-searches.
@seatedro seatedro closed this Nov 3, 2026
@seatedro seatedro reopened this Nov 3, 2026
@seatedro
seatedro enabled auto-merge November 3, 2026 12:43
@seatedro
seatedro merged commit a1ba939 into master Nov 3, 2026
16 of 17 checks passed
@seatedro
seatedro deleted the rohit/diff-core-myers-keep-finished branch November 3, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant