From f6ceabdebe0bb2f0399fd7ac539f419c6304bfda Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 12 Nov 2026 09:11:43 +0100 Subject: [PATCH] Add a test for pasting text into the keybindings menu The keybindings menu filters as you type. If you paste text that ends with a newline into it, the text filters the menu, and the newline then runs the selected item as if you had pressed Enter. The same happens in the other menus that filter as you type. Co-Authored-By: Claude Opus 5.5 --- pkg/integration/components/menu_driver.go | 9 +++++ .../paste_into_keybindings_menu.go | 36 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 3 files changed, 46 insertions(+) create mode 100644 pkg/integration/tests/filter_and_search/paste_into_keybindings_menu.go diff --git a/pkg/integration/components/menu_driver.go b/pkg/integration/components/menu_driver.go index e0d6133e6..a71bada76 100644 --- a/pkg/integration/components/menu_driver.go +++ b/pkg/integration/components/menu_driver.go @@ -66,6 +66,15 @@ func (self *MenuDriver) Filter(text string) *MenuDriver { return self } +// pastes the text the way a terminal does it. Only for menus that filter as you +// type. +func (self *MenuDriver) Paste(text string) *MenuDriver { + self.getViewDriver().IsFocused() + self.t.paste(text) + + return self +} + func (self *MenuDriver) LineCount(matcher *IntMatcher) *MenuDriver { self.getViewDriver().LineCount(matcher) diff --git a/pkg/integration/tests/filter_and_search/paste_into_keybindings_menu.go b/pkg/integration/tests/filter_and_search/paste_into_keybindings_menu.go new file mode 100644 index 000000000..d87f1cb54 --- /dev/null +++ b/pkg/integration/tests/filter_and_search/paste_into_keybindings_menu.go @@ -0,0 +1,36 @@ +package filter_and_search + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var PasteIntoKeybindingsMenu = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Pasting text that ends with a newline into the keybindings menu filters the menu without running the selected item", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFile("myfile", "myfile") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Files(). + IsFocused(). + Lines( + Contains(`??`).Contains(`myfile`).IsSelected(), + ). + Press(keys.Universal.OptionMenu) + + t.ExpectPopup().Menu(). + Title(Equals("Keybindings")). + Paste("stage all\n") + + t.Views().Files(). + Lines( + /* EXPECTED: + Contains(`??`).Contains(`myfile`), + ACTUAL: */ + Contains(`A `).Contains(`myfile`), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index e5949856a..aeded3da4 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -337,6 +337,7 @@ var tests = []*components.IntegrationTest{ filter_and_search.NestedFilter, filter_and_search.NestedFilterTransient, filter_and_search.NewSearch, + filter_and_search.PasteIntoKeybindingsMenu, filter_and_search.RerenderTheSearchedMainView, filter_and_search.SearchALongDiff, filter_and_search.SearchStatusAfterARerender,