summaryrefslogtreecommitdiffstats
path: root/pkg/gui/popup/popup_handler.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/gui/popup/popup_handler.go')
-rw-r--r--pkg/gui/popup/popup_handler.go35
1 files changed, 5 insertions, 30 deletions
diff --git a/pkg/gui/popup/popup_handler.go b/pkg/gui/popup/popup_handler.go
index 1eb81e800..1ca9cc3ee 100644
--- a/pkg/gui/popup/popup_handler.go
+++ b/pkg/gui/popup/popup_handler.go
@@ -8,20 +8,17 @@ import (
"github.com/jesseduffield/lazygit/pkg/common"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
- "github.com/sasha-s/go-deadlock"
)
type PopupHandler struct {
*common.Common
- index int
- deadlock.Mutex
createPopupPanelFn func(context.Context, types.CreatePopupPanelOpts) error
onErrorFn func() error
popContextFn func() error
currentContextFn func() types.Context
createMenuFn func(types.CreateMenuOptions) error
withWaitingStatusFn func(message string, f func(gocui.Task) error)
- withWaitingStatusSyncFn func(message string, f func() error)
+ withWaitingStatusSyncFn func(message string, f func() error) error
toastFn func(message string, kind types.ToastKind)
getPromptInputFn func() string
inDemo func() bool
@@ -37,14 +34,13 @@ func NewPopupHandler(
currentContextFn func() types.Context,
createMenuFn func(types.CreateMenuOptions) error,
withWaitingStatusFn func(message string, f func(gocui.Task) error),
- withWaitingStatusSyncFn func(message string, f func() error),
+ withWaitingStatusSyncFn func(message string, f func() error) error,
toastFn func(message string, kind types.ToastKind),
getPromptInputFn func() string,
inDemo func() bool,
) *PopupHandler {
return &PopupHandler{
Common: common,
- index: 0,
createPopupPanelFn: createPopupPanelFn,
onErrorFn: onErrorFn,
popContextFn: popContextFn,
@@ -80,25 +76,12 @@ func (self *PopupHandler) WithWaitingStatus(message string, f func(gocui.Task) e
}
func (self *PopupHandler) WithWaitingStatusSync(message string, f func() error) error {
- self.withWaitingStatusSyncFn(message, f)
- return nil
+ return self.withWaitingStatusSyncFn(message, f)
}
-func (self *PopupHandler) Error(err error) error {
- if err == gocui.ErrQuit {
- return err
- }
-
- return self.ErrorMsg(err.Error())
-}
-
-func (self *PopupHandler) ErrorMsg(message string) error {
- self.Lock()
- self.index++
- self.Unlock()
-
+func (self *PopupHandler) ErrorHandler(err error) error {
// Need to set bold here explicitly; otherwise it gets cancelled by the red colouring.
- coloredMessage := style.FgRed.SetBold().Sprint(strings.TrimSpace(message))
+ coloredMessage := style.FgRed.SetBold().Sprint(strings.TrimSpace(err.Error()))
if err := self.onErrorFn(); err != nil {
return err
}
@@ -111,10 +94,6 @@ func (self *PopupHandler) Alert(title string, message string) error {
}
func (self *PopupHandler) Confirm(opts types.ConfirmOpts) error {
- self.Lock()
- self.index++
- self.Unlock()
-
return self.createPopupPanelFn(context.Background(), types.CreatePopupPanelOpts{
Title: opts.Title,
Prompt: opts.Prompt,
@@ -124,10 +103,6 @@ func (self *PopupHandler) Confirm(opts types.ConfirmOpts) error {
}
func (self *PopupHandler) Prompt(opts types.PromptOpts) error {
- self.Lock()
- self.index++
- self.Unlock()
-
return self.createPopupPanelFn(context.Background(), types.CreatePopupPanelOpts{
Title: opts.Title,
Prompt: opts.InitialContent,