From 101424322ac02854f8703784c2feea49c2f18b39 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 19 Sep 2026 09:06:51 +0200 Subject: [PATCH] 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) --- pkg/gui/presentation/commits_test.go | 55 ++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/pkg/gui/presentation/commits_test.go b/pkg/gui/presentation/commits_test.go index eb5365f03..7efb5c5ae 100644 --- a/pkg/gui/presentation/commits_test.go +++ b/pkg/gui/presentation/commits_test.go @@ -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)