diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-16 14:46:53 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-17 19:13:40 +1100 |
commit | 1dd7307fde033dae5fececac15810a99e26c3d91 (patch) | |
tree | 4e851c9e3229a6fe3b4191f6311d05d7a9142960 /pkg/gui/filtering.go | |
parent | a90b6efded49abcfa2516db794d7875b0396f558 (diff) |
start moving commit panel handlers into controller
more
and more
move rebase commit refreshing into existing abstraction
and more
and more
WIP
and more
handling clicks
properly fix merge conflicts
update cheatsheet
lots more preparation to start moving things into controllers
WIP
better typing
expand on remotes controller
moving more code into controllers
Diffstat (limited to 'pkg/gui/filtering.go')
-rw-r--r-- | pkg/gui/filtering.go | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/pkg/gui/filtering.go b/pkg/gui/filtering.go index df007b69a..df4fa848d 100644 --- a/pkg/gui/filtering.go +++ b/pkg/gui/filtering.go @@ -5,17 +5,27 @@ import ( "github.com/jesseduffield/lazygit/pkg/gui/types" ) -func (gui *Gui) validateNotInFilterMode() (bool, error) { +func (gui *Gui) validateNotInFilterMode() bool { if gui.State.Modes.Filtering.Active() { - err := gui.PopupHandler.Ask(popup.AskOpts{ - Title: gui.Tr.MustExitFilterModeTitle, - Prompt: gui.Tr.MustExitFilterModePrompt, + _ = gui.c.Ask(popup.AskOpts{ + Title: gui.c.Tr.MustExitFilterModeTitle, + Prompt: gui.c.Tr.MustExitFilterModePrompt, HandleConfirm: gui.exitFilterMode, }) - return false, err + return false + } + return true +} + +func (gui *Gui) outsideFilterMode(f func() error) func() error { + return func() error { + if !gui.validateNotInFilterMode() { + return nil + } + + return f() } - return true, nil } func (gui *Gui) exitFilterMode() error { @@ -28,7 +38,7 @@ func (gui *Gui) clearFiltering() error { gui.State.ScreenMode = SCREEN_NORMAL } - return gui.refreshSidePanels(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}}) + return gui.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}}) } func (gui *Gui) setFiltering(path string) error { @@ -37,11 +47,11 @@ func (gui *Gui) setFiltering(path string) error { gui.State.ScreenMode = SCREEN_HALF } - if err := gui.pushContext(gui.State.Contexts.BranchCommits); err != nil { + if err := gui.c.PushContext(gui.State.Contexts.BranchCommits); err != nil { return err } - return gui.refreshSidePanels(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() { + return gui.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() { gui.State.Contexts.BranchCommits.GetPanelState().SetSelectedLineIdx(0) }}) } |