From 1b901c7187d7d6d886c495d7bc441fcfc34f25bd Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 5 Aug 2026 11:57:15 +0200 Subject: [PATCH] Scroll the selection into view after a filtering mode change The commit list a filtering mode change leaves behind has nothing to do with the one that was showing, so the scroll position it inherits says nothing about where the selection ended up, and the selection can land anywhere off screen. PostRefreshUpdate only moves the cursor within the existing scroll position, so ask for the scroll separately, the way the commits refresh does when it moves the selection itself. Exiting filtering mode looked like it worked, but only by accident: the commits refresh recognizes the commit that was selected before it ran, selects it again at its new index, and scrolls because the index moved. That does nothing for the case where the commit is gone from the list, or for entering filtering mode, where we select the first commit ourselves. --- pkg/gui/controllers/helpers/mode_helper.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/gui/controllers/helpers/mode_helper.go b/pkg/gui/controllers/helpers/mode_helper.go index 68f7ea149..6e5139744 100644 --- a/pkg/gui/controllers/helpers/mode_helper.go +++ b/pkg/gui/controllers/helpers/mode_helper.go @@ -270,6 +270,11 @@ func (self *ModeHelper) changeFiltering(setFilter func(), selectCommit func()) e selectCommit() self.c.PostRefreshUpdate(self.c.Contexts().LocalCommits) + // The list we just selected in has nothing to do with the one + // that was showing, so wherever it was scrolled to says nothing + // about where the selection now is. PostRefreshUpdate leaves the + // scroll position alone, so ask for it separately. + self.c.Contexts().LocalCommits.FocusLine(true) return nil }, })