From 63655288a43540501e1d6172429d3664da55c997 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 7 Jul 2025 13:41:12 +0200 Subject: [PATCH] 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. --- pkg/gui/patch_exploring/focus.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/gui/patch_exploring/focus.go b/pkg/gui/patch_exploring/focus.go index 3548f09d4..cf917cd4d 100644 --- a/pkg/gui/patch_exploring/focus.go +++ b/pkg/gui/patch_exploring/focus.go @@ -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) }