From 3f546f726939ed88e901bf8cda154b03140f9558 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 7 Jul 2025 11:50:22 +0200 Subject: [PATCH 1/3] Cleanup: fix comment --- pkg/gui/context/list_context_trait.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/gui/context/list_context_trait.go b/pkg/gui/context/list_context_trait.go index cb435c035..cc1d402c0 100644 --- a/pkg/gui/context/list_context_trait.go +++ b/pkg/gui/context/list_context_trait.go @@ -30,7 +30,7 @@ func (self *ListContextTrait) FocusLine() { // Doing this at the end of the layout function because we need the view to be // resized before we focus the line, otherwise if we're in accordion mode - // the view could be squashed and won't how to adjust the cursor/origin. + // the view could be squashed and won't know how to adjust the cursor/origin. // Also, refreshing the viewport needs to happen after the view has been resized. self.c.AfterLayout(func() error { oldOrigin, _ := self.GetViewTrait().ViewPortYBounds() From 29fc46dc62dbcab4dfee6ba6b3cbc8f2f2deecd8 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 7 Jul 2025 11:40:32 +0200 Subject: [PATCH 2/3] Cleanup: remove unused method Focus from PatchExplorerContext --- pkg/gui/context/patch_explorer_context.go | 5 ----- pkg/gui/types/context.go | 1 - 2 files changed, 6 deletions(-) diff --git a/pkg/gui/context/patch_explorer_context.go b/pkg/gui/context/patch_explorer_context.go index c9144e1ab..79d585a12 100644 --- a/pkg/gui/context/patch_explorer_context.go +++ b/pkg/gui/context/patch_explorer_context.go @@ -94,11 +94,6 @@ func (self *PatchExplorerContext) Render() { self.c.Render() } -func (self *PatchExplorerContext) Focus() { - self.FocusSelection() - self.c.Render() -} - func (self *PatchExplorerContext) setContent() { self.GetView().SetContent(self.GetContentToRender()) } diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go index 1c9759486..bbca0147a 100644 --- a/pkg/gui/types/context.go +++ b/pkg/gui/types/context.go @@ -192,7 +192,6 @@ type IPatchExplorerContext interface { GetIncludedLineIndices() []int RenderAndFocus() Render() - Focus() GetContentToRender() string NavigateTo(selectedLineIdx int) GetMutex() *deadlock.Mutex From 63655288a43540501e1d6172429d3664da55c997 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 7 Jul 2025 13:41:12 +0200 Subject: [PATCH 3/3] 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) }