From 15d17e16dd1be12192e783c856b3da1e4a4bf831 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 18 Aug 2024 21:11:21 +0200 Subject: [PATCH] Call ReApplySearch after layout This fixes a possible crash when exiting filter mode in the commits panel. --- pkg/gui/controllers/helpers/refresh_helper.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index e29879b9d..579bc9d3e 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -765,8 +765,18 @@ func (self *RefreshHelper) refreshView(context types.Context) error { err := self.c.PostRefreshUpdate(context) - // Re-applying the search must be done after re-rendering the view though, - // so that the "x of y" status is shown correctly. - self.searchHelper.ReApplySearch(context) + self.c.AfterLayout(func() error { + // Re-applying the search must be done after re-rendering the view though, + // so that the "x of y" status is shown correctly. + // + // Also, it must be done after layout, because otherwise FocusPoint + // hasn't been called yet (see ListContextTrait.FocusLine), which means + // that the scroll position might be such that the entire visible + // content is outside the viewport. And this would cause problems in + // searchModelCommits. + self.searchHelper.ReApplySearch(context) + return nil + }) + return err }