From 207373018667a6b1fffcd382c1e383e267df8a50 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 18 Aug 2023 07:47:26 +0200 Subject: [PATCH] Fix the commit graph display after selection jumps in commits view When navigating in the commits view to a line that is out of view (e.g. by pressing , or . to scroll by page, or < or > to scroll to the top or bottom), the commit graph was not correctly highlighted. Fix this by rerendering the viewport in this case. --- pkg/gui/context/list_context_trait.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/gui/context/list_context_trait.go b/pkg/gui/context/list_context_trait.go index 54e3ab9ea..900be019c 100644 --- a/pkg/gui/context/list_context_trait.go +++ b/pkg/gui/context/list_context_trait.go @@ -35,7 +35,18 @@ func (self *ListContextTrait) FocusLine() { // 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 self.c.AfterLayout(func() error { + oldOrigin, _ := self.GetViewTrait().ViewPortYBounds() + self.GetViewTrait().FocusPoint(self.list.GetSelectedLineIdx()) + + // If FocusPoint() caused the view to scroll (because the selected line + // was out of view before), we need to rerender the view port again. + // This can happen when pressing , or . to scroll by pages, or < or > to + // jump to the top or bottom. + newOrigin, _ := self.GetViewTrait().ViewPortYBounds() + if self.refreshViewportOnChange && oldOrigin != newOrigin { + self.refreshViewport() + } return nil })