diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index a5be655a1..cac9310d1 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -490,9 +490,9 @@ func (self *RefreshHelper) refreshBranches(refreshWorktrees bool, keepBranchSele self.refreshView(self.c.Contexts().Worktrees) } - self.refreshView(self.c.Contexts().Branches) - if !keepBranchSelectionIndex && prevSelectedBranch != nil { + self.searchHelper.ReApplyFilter(self.c.Contexts().Branches) + _, idx, found := lo.FindIndexOf(self.c.Contexts().Branches.GetItems(), func(b *models.Branch) bool { return b.Name == prevSelectedBranch.Name }) if found { @@ -500,6 +500,8 @@ func (self *RefreshHelper) refreshBranches(refreshWorktrees bool, keepBranchSele } } + self.refreshView(self.c.Contexts().Branches) + // Need to re-render the commits view because the visualization of local // branch heads might have changed self.c.Mutexes().LocalCommitsMutex.Lock()