jesseduffield.lazygit/pkg/integration/tests/misc/recent_repos_with_long_names.go
Stefan Haller f113736aac Truncate the repo and branch names in the recent repos menu
Each column of a menu is padded to the width of its widest entry, so a
single long name in the first two columns of the recent repos menu
pushes the path column off the right edge for every entry. Anyone whose
worktree directories are named after their branches hits this: with a
90 column menu and one 42 character name, the path column starts at
column 86 of 88.

Truncate both names to 30 characters, and put the ones that got
truncated into the item's tooltip, so that the full text is still on
screen for the selected entry. Filtering keeps matching the full names
and the full path, which the columns no longer show in their entirety.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 18:38:57 +02:00

47 lines
1.5 KiB
Go

package misc
import (
"path/filepath"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var RecentReposWithLongNames = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Long repo and branch names are truncated in the recent repositories menu, and shown in full in the tooltip",
ExtraCmdArgs: []string{},
ExtraEnvVars: map[string]string{
"SHOW_RECENT_REPOS": "true",
},
Skip: false,
SetupConfig: func(cfg *config.AppConfig) {
// the first entry is the repo we're in, so it isn't offered
current, _ := filepath.Abs(".")
target, _ := filepath.Abs("../repo-with-a-name-that-is-far-too-long")
cfg.GetAppState().RecentRepos = []string{current, target}
},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")
shell.NewBranch("branch-with-a-name-that-is-too-long")
shell.CloneNonBare("repo-with-a-name-that-is-far-too-long")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.ExpectPopup().Menu().
Title(Equals("Recent repositories")).
Lines(
Contains("repo-with-a-name-that-is-far-… branch-with-a-name-that-is-to…").IsSelected(),
Contains("Cancel"),
).
Tooltip(Equals("Repo: repo-with-a-name-that-is-far-too-long\nBranch: branch-with-a-name-that-is-too-long")).
// Filtering matches the full names, including the part that the
// menu truncates
Filter("too-long").
Lines(
Contains("repo-with-a-name-that-is-far-…").IsSelected(),
).
Confirm()
t.Views().Status().Content(Contains("repo-with-a-name"))
},
})