1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-06 22:33:07 +02:00

Fix scrolling hunk into view when selecting next hunk

If the hunk to be selected was partially scrolled offscreen, the view wouldn't
scroll enough to make it completely visible (the last line of the hunk was still
offscreen).

This is only a minimal fix for a pressing problem. The code to handle scrolling
after selection changes has lots of problems, and is also inconsistent between
list views and the patch explorer, but cleaning this up needs more time than I
have right now.
This commit is contained in:
Stefan Haller
2025-07-07 13:41:12 +02:00
parent 29fc46dc62
commit 63655288a4

View File

@ -22,7 +22,7 @@ func calculateNewOriginWithNeededAndWantedIdx(currentOrigin int, bufferHeight in
allowedChange := bottom - needToSeeIdx
return origin - min(requiredChange, allowedChange)
} else if wantToSeeIdx >= bottom {
requiredChange := wantToSeeIdx - bottom
requiredChange := wantToSeeIdx + 1 - bottom
allowedChange := needToSeeIdx - origin
return origin + min(requiredChange, allowedChange)
}