Demonstrate that a commit list's columns are as wide as the visible lines need

The commits panel renders only the lines that are on screen, so the width
of a column follows what happens to be visible, and a column all of whose
visible lines are empty disappears altogether. Scrolling past the pending
rebase todos takes the action column away with them, and everything to its
right jumps to the left.

Cover the same problem for two more columns: the hash column, which goes
away while only hashless todos such as "update-ref" are on screen, and the
date column in the expanded commits panel, which is as narrow as the time
format while only commits from today are on screen.

This file is deliberately left un-gofumpt'd: gofumpt indents the body of
the commented-out block by a tab, which would fill the diff of the commit
that swaps the two blocks with whitespace-only changes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-09-19 10:16:04 +02:00
co-authored by Claude Opus 5
parent 56c2ffb8f8
commit 101424322a
+55
View File
@@ -274,6 +274,12 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitHashSet: set.New[string](),
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
/* EXPECTED:
expected: formatExpected(`
hash4 ○ commit4
hash5 ○ commit5
`),
ACTUAL: */
expected: formatExpected(`
hash4 ○ commit4
hash5 ○ commit5
@@ -338,6 +344,31 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
hash2 pick commit2
`),
},
{
testName: "only showing TODO commits that have no hash",
commitOpts: []models.NewCommitOpts{
{Name: "refs/heads/branch1", Action: todo.UpdateRef},
{Name: "refs/heads/branch2", Action: todo.UpdateRef},
{Name: "commit1", Hash: "hash1", Parents: []string{"hash2"}, Action: todo.Pick},
{Name: "commit2", Hash: "hash2", Parents: []string{"hash3"}},
},
startIdx: 0,
endIdx: 2,
showGraph: false,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitHashSet: set.New[string](),
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
/* EXPECTED:
expected: formatExpected(`
update-ref branch1
update-ref branch2
`),
ACTUAL: */
expected: formatExpected(`
update-ref branch1
update-ref branch2
`),
},
{
testName: "graph in divergence view - all commits visible",
commitOpts: []models.NewCommitOpts{
@@ -530,6 +561,30 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
hash2 2019-12-20 Jesse Duffield commit2
`),
},
{
testName: "only showing commits from today",
commitOpts: []models.NewCommitOpts{
{Name: "commit1", Hash: "hash1", UnixTimestamp: 1577844184, AuthorName: "Jesse Duffield"},
{Name: "commit2", Hash: "hash2", UnixTimestamp: 1576844184, AuthorName: "Jesse Duffield"},
},
fullDescription: true,
timeFormat: "2006-01-02",
shortTimeFormat: "3:04PM",
startIdx: 0,
endIdx: 1,
showGraph: false,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitHashSet: set.New[string](),
now: time.Date(2020, 1, 1, 5, 3, 4, 0, time.UTC),
/* EXPECTED:
expected: formatExpected(`
hash1 2:03AM Jesse Duffield commit1
`),
ACTUAL: */
expected: formatExpected(`
hash1 2:03AM Jesse Duffield commit1
`),
},
}
oldColorLevel := color.ForceSetColorLevel(terminfo.ColorLevelNone)