1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

fix popup focus issue

This commit is contained in:
Jesse Duffield
2022-08-01 21:58:49 +10:00
parent fab2e14b55
commit debc58b6c5
6 changed files with 31 additions and 45 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/common"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
@ -17,7 +18,8 @@ type PopupHandler struct {
sync.Mutex
createPopupPanelFn func(types.CreatePopupPanelOpts) error
onErrorFn func() error
closePopupFn func() error
popContextFn func() error
currentContextFn func() types.Context
createMenuFn func(types.CreateMenuOptions) error
withWaitingStatusFn func(message string, f func() error) error
toastFn func(message string)
@ -30,7 +32,8 @@ func NewPopupHandler(
common *common.Common,
createPopupPanelFn func(types.CreatePopupPanelOpts) error,
onErrorFn func() error,
closePopupFn func() error,
popContextFn func() error,
currentContextFn func() types.Context,
createMenuFn func(types.CreateMenuOptions) error,
withWaitingStatusFn func(message string, f func() error) error,
toastFn func(message string),
@ -41,7 +44,8 @@ func NewPopupHandler(
index: 0,
createPopupPanelFn: createPopupPanelFn,
onErrorFn: onErrorFn,
closePopupFn: closePopupFn,
popContextFn: popContextFn,
currentContextFn: currentContextFn,
createMenuFn: createMenuFn,
withWaitingStatusFn: withWaitingStatusFn,
toastFn: toastFn,
@ -93,11 +97,10 @@ func (self *PopupHandler) Confirm(opts types.ConfirmOpts) error {
self.Unlock()
return self.createPopupPanelFn(types.CreatePopupPanelOpts{
Title: opts.Title,
Prompt: opts.Prompt,
HandleConfirm: opts.HandleConfirm,
HandleClose: opts.HandleClose,
HandlersManageFocus: opts.HandlersManageFocus,
Title: opts.Title,
Prompt: opts.Prompt,
HandleConfirm: opts.HandleConfirm,
HandleClose: opts.HandleClose,
})
}
@ -139,8 +142,8 @@ func (self *PopupHandler) WithLoaderPanel(message string, f func() error) error
}
self.Lock()
if index == self.index {
_ = self.closePopupFn()
if index == self.index && self.currentContextFn().GetKey() == context.CONFIRMATION_CONTEXT_KEY {
_ = self.popContextFn()
}
self.Unlock()
})