1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-03 13:21:56 +02:00

Fix escape not cancelling filter mode, but closing the menu instead

When filtering is on in a menu, pressing esc should only cancel the filter, but
not close the menu.
This commit is contained in:
Stefan Haller 2023-08-30 22:31:04 +02:00
parent ce91de76e4
commit de4224bbe4
3 changed files with 42 additions and 0 deletions

View File

@ -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()
}

View File

@ -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()
},
})

View File

@ -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,