summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/gui/controllers/menu_controller.go5
-rw-r--r--pkg/integration/tests/filter_and_search/filter_menu_cancel_filter_with_escape.go36
-rw-r--r--pkg/integration/tests/test_list.go1
3 files changed, 42 insertions, 0 deletions
diff --git a/pkg/gui/controllers/menu_controller.go b/pkg/gui/controllers/menu_controller.go
index c9ba2c701..108bd9cf7 100644
--- a/pkg/gui/controllers/menu_controller.go
+++ b/pkg/gui/controllers/menu_controller.go
@@ -65,6 +65,11 @@ func (self *MenuController) press() error {
}
func (self *MenuController) close() error {
+ if self.context().IsFiltering() {
+ self.c.Helpers().Search.Cancel()
+ return nil
+ }
+
return self.c.PopContext()
}
diff --git a/pkg/integration/tests/filter_and_search/filter_menu_cancel_filter_with_escape.go b/pkg/integration/tests/filter_and_search/filter_menu_cancel_filter_with_escape.go
new file mode 100644
index 000000000..8c84e1827
--- /dev/null
+++ b/pkg/integration/tests/filter_and_search/filter_menu_cancel_filter_with_escape.go
@@ -0,0 +1,36 @@
+package filter_and_search
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var FilterMenuCancelFilterWithEscape = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Filtering the keybindings menu, then pressing esc to turn off the filter",
+ 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().
+ Title(Equals("Keybindings")).
+ Filter("Toggle staged").
+ Lines(
+ // menu has filtered down to the one item that matches the filter
+ Contains(`Toggle staged`).IsSelected(),
+ )
+
+ // Escape should cancel the filter, not close the menu
+ t.GlobalPress(keys.Universal.Return)
+ t.ExpectPopup().Menu().
+ Title(Equals("Keybindings")).
+ LineCount(GreaterThan(1))
+
+ // Another escape closes the menu
+ t.GlobalPress(keys.Universal.Return)
+ t.Views().Files().IsFocused()
+ },
+})
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index 0a50b7441..c669bbae3 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -122,6 +122,7 @@ var tests = []*components.IntegrationTest{
filter_and_search.FilterFiles,
filter_and_search.FilterFuzzy,
filter_and_search.FilterMenu,
+ filter_and_search.FilterMenuCancelFilterWithEscape,
filter_and_search.FilterRemoteBranches,
filter_and_search.NestedFilter,
filter_and_search.NestedFilterTransient,