mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +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:
@ -65,6 +65,11 @@ func (self *MenuController) press() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *MenuController) close() error {
|
func (self *MenuController) close() error {
|
||||||
|
if self.context().IsFiltering() {
|
||||||
|
self.c.Helpers().Search.Cancel()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return self.c.PopContext()
|
return self.c.PopContext()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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()
|
||||||
|
},
|
||||||
|
})
|
@ -122,6 +122,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
filter_and_search.FilterFiles,
|
filter_and_search.FilterFiles,
|
||||||
filter_and_search.FilterFuzzy,
|
filter_and_search.FilterFuzzy,
|
||||||
filter_and_search.FilterMenu,
|
filter_and_search.FilterMenu,
|
||||||
|
filter_and_search.FilterMenuCancelFilterWithEscape,
|
||||||
filter_and_search.FilterRemoteBranches,
|
filter_and_search.FilterRemoteBranches,
|
||||||
filter_and_search.NestedFilter,
|
filter_and_search.NestedFilter,
|
||||||
filter_and_search.NestedFilterTransient,
|
filter_and_search.NestedFilterTransient,
|
||||||
|
Reference in New Issue
Block a user