From 0720a05ae41ad3a55d551b6c1726bdbcbf215c1e Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 19 Sep 2026 09:46:34 +0200 Subject: [PATCH] Hand the whole reflog to GetReflogCommitListDisplayStrings The reflog commits context slices the visible lines out itself and passes only those, so the function has no way to look at the rest of the list. A following commit needs the oldest entry to work out how much width the date column needs. Take the whole list along with the range to render, the way GetCommitListDisplayStrings already does. Co-Authored-By: Claude Opus 5 (1M context) --- pkg/gui/context/reflog_commits_context.go | 9 +++------ pkg/gui/presentation/reflog_commits.go | 8 ++++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/gui/context/reflog_commits_context.go b/pkg/gui/context/reflog_commits_context.go index 6358fbbb0..71314bf66 100644 --- a/pkg/gui/context/reflog_commits_context.go +++ b/pkg/gui/context/reflog_commits_context.go @@ -27,13 +27,10 @@ func NewReflogCommitsContext(c *ContextCommon) *ReflogCommitsContext { ) getDisplayStrings := func(startIdx int, endIdx int) [][]string { - commits := viewModel.GetItems() - if startIdx >= len(commits) { - return nil - } - return presentation.GetReflogCommitListDisplayStrings( - commits[startIdx:endIdx], + viewModel.GetItems(), + startIdx, + endIdx, c.State().GetRepoState().GetScreenMode() != types.SCREEN_NORMAL, c.Modes().CherryPicking.SelectedHashSet(), c.Modes().Diffing.Ref, diff --git a/pkg/gui/presentation/reflog_commits.go b/pkg/gui/presentation/reflog_commits.go index b84a10e59..785776864 100644 --- a/pkg/gui/presentation/reflog_commits.go +++ b/pkg/gui/presentation/reflog_commits.go @@ -12,7 +12,11 @@ import ( "github.com/samber/lo" ) -func GetReflogCommitListDisplayStrings(commits []*models.Commit, fullDescription bool, cherryPickedCommitHashSet *set.Set[string], diffName string, now time.Time, timeFormat string, shortTimeFormat string, parseEmoji bool) [][]string { +func GetReflogCommitListDisplayStrings(commits []*models.Commit, startIdx int, endIdx int, fullDescription bool, cherryPickedCommitHashSet *set.Set[string], diffName string, now time.Time, timeFormat string, shortTimeFormat string, parseEmoji bool) [][]string { + if startIdx >= len(commits) { + return nil + } + var displayFunc func(*models.Commit, reflogCommitDisplayAttributes) []string if fullDescription { displayFunc = getFullDescriptionDisplayStringsForReflogCommit @@ -20,7 +24,7 @@ func GetReflogCommitListDisplayStrings(commits []*models.Commit, fullDescription displayFunc = getDisplayStringsForReflogCommit } - return lo.Map(commits, func(commit *models.Commit, _ int) []string { + return lo.Map(commits[startIdx:endIdx], func(commit *models.Commit, _ int) []string { diffed := commit.Hash() == diffName cherryPicked := cherryPickedCommitHashSet.Includes(commit.Hash()) return displayFunc(commit,