diff --git a/pkg/gui/controllers/filtering_menu_action.go b/pkg/gui/controllers/filtering_menu_action.go index 3a109a887..2ed072676 100644 --- a/pkg/gui/controllers/filtering_menu_action.go +++ b/pkg/gui/controllers/filtering_menu_action.go @@ -4,6 +4,7 @@ import ( "fmt" "strings" + "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/types" ) @@ -122,7 +123,7 @@ func (self *FilteringMenuAction) setFiltering() error { self.c.Context().Push(self.c.Contexts().LocalCommits, types.OnFocusOpts{}) - self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() { + self.c.Refresh(types.RefreshOptions{Scope: helpers.ScopesToRefreshWhenFilteringModeChanges(), Then: func() { self.c.Contexts().LocalCommits.SetSelection(0) self.c.Contexts().LocalCommits.HandleFocus(types.OnFocusOpts{}) }}) diff --git a/pkg/gui/controllers/helpers/mode_helper.go b/pkg/gui/controllers/helpers/mode_helper.go index a5960697a..702825c58 100644 --- a/pkg/gui/controllers/helpers/mode_helper.go +++ b/pkg/gui/controllers/helpers/mode_helper.go @@ -168,7 +168,7 @@ func (self *ModeHelper) ClearFiltering() error { } self.c.Refresh(types.RefreshOptions{ - Scope: []types.RefreshableView{types.COMMITS}, + Scope: ScopesToRefreshWhenFilteringModeChanges(), Then: func() { // Find the commit that was last selected in filtering mode, and select it again after refreshing if !self.c.Contexts().LocalCommits.SelectCommitByHash(selectedCommitHash) { @@ -185,6 +185,17 @@ func (self *ModeHelper) ClearFiltering() error { return nil } +// Stashes really only need to be refreshed when filtering by path, not by author, but it's too much +// work to distinguish this, and refreshing stashes is fast, so we don't bother +func ScopesToRefreshWhenFilteringModeChanges() []types.RefreshableView { + return []types.RefreshableView{ + types.COMMITS, + types.SUB_COMMITS, + types.REFLOG, + types.STASH, + } +} + func (self *ModeHelper) SetSuppressRebasingMode(value bool) { self.suppressRebasingMode = value }