jesseduffield.lazygit/pkg/integration/tests/ui/empty_menu.go
Stefan Haller fb761892aa Filter the keybindings menu as you type
Looking up a keybinding is a search, so the menu that lists them is the
one that most wants this. Its items do have keys, but only as a reminder
of what they do outside the menu, so nothing is lost by not binding them.

The prompt in front of the input field says what '@' does. It only ever
showed up while the user was typing in the search prompt, so it could
afford to be wordy; on a row that is on screen for as long as the menu
is, it can't.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 20:41:22 +02:00

42 lines
1 KiB
Go

package ui
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var EmptyMenu = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Verify that we don't crash on an empty menu",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsFocused().
Press(keys.Universal.OptionMenu)
t.ExpectPopup().Menu().
// a string that filters everything out
Filter("ljasldkjaslkdjalskdjalsdjaslkd")
t.Views().Menu().
IsFocused().
IsEmpty().
// space is filter text in this menu, so we confirm with enter
Press(keys.Universal.ConfirmMenu).
Tap(func() {
t.ExpectToast(Equals("Disabled: No item selected"))
}).
// escape the filter
PressEscape().
// escape the view
PressEscape()
// back in the files view, selecting the non-existing menu item was a no-op
t.Views().Files().
IsFocused()
},
})