diff --git a/cli/internal/tui/list_view.go b/cli/internal/tui/list_view.go index e1ae6114..dc9d1f9e 100644 --- a/cli/internal/tui/list_view.go +++ b/cli/internal/tui/list_view.go @@ -226,6 +226,8 @@ func (l listView) pane(width, height int) []string { inner := max(1, width-2) r, ok := l.highlighted() switch { + case !ok && len(l.rows) == 0: + return paneBox(nil, inner, width, height) case !ok: return paneBox([]string{"", DefaultStyles.Muted.Render("nothing matches"), DefaultStyles.Faint.Render("Try fewer search terms")}, inner, width, height) case r.detail == nil: diff --git a/cli/internal/tui/page_render.go b/cli/internal/tui/page_render.go index 624f233b..4db80b1a 100644 --- a/cli/internal/tui/page_render.go +++ b/cli/internal/tui/page_render.go @@ -293,9 +293,11 @@ func (m PageViewModel) prompt() string { return "" } -// fitHints is " " and the hints in room columns, shedding what the screen -// already says first: moving, then leaving, then every label but the keys. -// Empty when not even the keys fit. +// fitHints is " " and the hints in room columns. A screen lists its hints +// most important first and esc last. What the screen already says goes +// first: moving, then leaving, then the least important hints one at a +// time from the end, and only when three labelled hints no longer fit, every +// label but the keys. Empty when not even the keys fit. func fitHints(hints []hint, room int) string { keysOnly := make([]hint, len(hints)) for i, h := range hints { @@ -306,7 +308,12 @@ func fitHints(hints []hint, room int) string { } still := slices.DeleteFunc(slices.Clone(hints), func(h hint) bool { return h.key == "↑↓" }) staying := slices.DeleteFunc(slices.Clone(still), func(h hint) bool { return h.key == "esc" }) - for _, candidate := range [][]hint{hints, still, staying, keysOnly} { + candidates := [][]hint{hints, still, staying} + for n := len(staying) - 1; n >= min(3, len(staying)); n-- { + candidates = append(candidates, staying[:n]) + } + candidates = append(candidates, keysOnly) + for _, candidate := range candidates { if line := " " + keyHints(candidate...); len(candidate) > 0 && ansi.StringWidth(line) <= room { return line }