mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-12 11:15:00 +02:00
1dd7307fde
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
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
package gui
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/gui/popup"
|
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
)
|
|
|
|
func (gui *Gui) validateNotInFilterMode() bool {
|
|
if gui.State.Modes.Filtering.Active() {
|
|
_ = gui.c.Ask(popup.AskOpts{
|
|
Title: gui.c.Tr.MustExitFilterModeTitle,
|
|
Prompt: gui.c.Tr.MustExitFilterModePrompt,
|
|
HandleConfirm: gui.exitFilterMode,
|
|
})
|
|
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (gui *Gui) outsideFilterMode(f func() error) func() error {
|
|
return func() error {
|
|
if !gui.validateNotInFilterMode() {
|
|
return nil
|
|
}
|
|
|
|
return f()
|
|
}
|
|
}
|
|
|
|
func (gui *Gui) exitFilterMode() error {
|
|
return gui.clearFiltering()
|
|
}
|
|
|
|
func (gui *Gui) clearFiltering() error {
|
|
gui.State.Modes.Filtering.Reset()
|
|
if gui.State.ScreenMode == SCREEN_HALF {
|
|
gui.State.ScreenMode = SCREEN_NORMAL
|
|
}
|
|
|
|
return gui.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}})
|
|
}
|
|
|
|
func (gui *Gui) setFiltering(path string) error {
|
|
gui.State.Modes.Filtering.SetPath(path)
|
|
if gui.State.ScreenMode == SCREEN_NORMAL {
|
|
gui.State.ScreenMode = SCREEN_HALF
|
|
}
|
|
|
|
if err := gui.c.PushContext(gui.State.Contexts.BranchCommits); err != nil {
|
|
return err
|
|
}
|
|
|
|
return gui.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() {
|
|
gui.State.Contexts.BranchCommits.GetPanelState().SetSelectedLineIdx(0)
|
|
}})
|
|
}
|