Repository navigation
fix: prevent cursor-overflow panic on PR reload that shrinks the diff - #574
Merged
Merged
Conversation
A PR `:e` reload can replace the diff with a shorter one while leaving `cursor_line` parked past the new end (the same-head reload branch, and a restored overview cursor captured from the taller old diff, never reclamp it). The next `cursor_down` then clamps the cursor *up* to the new `max_cursor_line` — below `prev_cursor` — underflowing the `cursor_line - prev_cursor` usize subtraction and panicking with "attempt to subtract with overflow" at navigation.rs. - cursor_down: use `saturating_sub` for the cursor-movement delta, matching the existing `cursor_up` siblings. - finish_pr_reload / reload_pull_request_with_backend: clamp `cursor_line` into the reloaded diff's bounds after the swap/restore. - add a regression test that reproduces the stale-cursor overflow. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
I want to test this before I publish. |
joshvito
commented
Aug 10, 2026
joshvito
force-pushed
the
fix/pr-reload-cursor-overflow
branch
from
August 10, 2026 15:56
4c0bc1a to
19875ba
Compare
joshvito
marked this pull request as ready for review
August 10, 2026 15:59
agavra
approved these changes
Aug 11, 2026
1 task
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 #573
A PR
:ereload can replace the diff with a shorter one while leavingcursor_lineparked past the new end (the same-head reload branch, and a restored overview cursor captured from the taller old diff, never reclamp it). The nextcursor_downthen clamps the cursor up to the newmax_cursor_line— belowprev_cursor— underflowing thecursor_line - prev_cursorusize subtraction and panicking with "attempt to subtract with overflow" at navigation.rs.saturating_subfor the cursor-movement delta, matching the existingcursor_upsiblings.cursor_lineinto the reloaded diff's bounds after the swap/restore.