mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-06 22:33:07 +02:00
Refresh all affected scopes when entering/exiting filtering
Since filtering switches to half-screen mode in the local commits panel, most people probably didn't notice, but we do also filter those other views. So when leaving half-screen mode (but not filtering), you could switch to sub-commits or stashes, and those would show the filtered view only after the next refresh (e.g. after a background fetch). It's worse when leaving filtering, because this goes back to normal screen mode, and you would often see an empty stashes panel after that (until the next background fetch), which is quite confusing. I also find it questionable to always switch focus to the commits panel when entering filtering. If it is initiated from subcommits, reflog, or stashes, maybe we want to stay there. I'm not changing this now since I'm unsure how much people rely on the current behavior.
This commit is contained in:
@ -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{})
|
||||
}})
|
||||
|
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user