1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-04 03:48:07 +02:00

better handling of clearing the search

This commit is contained in:
Jesse Duffield 2020-02-24 22:15:10 +11:00
parent 1f5ccab1ce
commit 78b62be96f
4 changed files with 9 additions and 8 deletions

View File

@ -400,7 +400,7 @@ func (gui *Gui) onBranchesTabClick(tabIndex int) error {
func (gui *Gui) switchBranchesPanelContext(context string) error {
branchesView := gui.getBranchesView()
branchesView.Context = context
branchesView.ClearSearch()
gui.onSearchEscape()
contextTabIndexMap := map[string]int{
"local-branches": 0,

View File

@ -623,7 +623,7 @@ func (gui *Gui) onCommitsTabClick(tabIndex int) error {
func (gui *Gui) switchCommitsPanelContext(context string) error {
commitsView := gui.getCommitsView()
commitsView.Context = context
commitsView.ClearSearch()
gui.onSearchEscape()
contextTabIndexMap := map[string]int{
"branch-commits": 0,

View File

@ -346,8 +346,7 @@ func (gui *Gui) onFocusLost(v *gocui.View, newView *gocui.View) error {
return nil
}
if v.IsSearching() && newView.Name() != "search" {
gui.State.Searching.isSearching = false
v.ClearSearch()
gui.onSearchEscape()
}
switch v.Name() {
case "branches":

View File

@ -72,7 +72,11 @@ func (gui *Gui) onSelectItemWrapper(innerFunc func(int) error) func(int, int, in
func (gui *Gui) onSearchEscape() error {
gui.State.Searching.isSearching = false
gui.State.Searching.view = nil
if gui.State.Searching.view != nil {
gui.State.Searching.view.ClearSearch()
gui.State.Searching.view = nil
}
return nil
}
@ -81,9 +85,7 @@ func (gui *Gui) handleSearchEscape(g *gocui.Gui, v *gocui.View) error {
return err
}
if err := gui.onSearchEscape(); err != nil {
return err
}
gui.onSearchEscape()
return nil
}