1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-25 22:32:13 +02:00

Remove PopupHandler index and mutex

It doesn't seem to be used.
This commit is contained in:
Stefan Haller
2024-04-14 14:59:42 +02:00
parent 145795c0b0
commit 8a77e51576

View File

@@ -8,13 +8,10 @@ import (
"github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/common"
"github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/sasha-s/go-deadlock"
) )
type PopupHandler struct { type PopupHandler struct {
*common.Common *common.Common
index int
deadlock.Mutex
createPopupPanelFn func(context.Context, types.CreatePopupPanelOpts) error createPopupPanelFn func(context.Context, types.CreatePopupPanelOpts) error
onErrorFn func() error onErrorFn func() error
popContextFn func() error popContextFn func() error
@@ -44,7 +41,6 @@ func NewPopupHandler(
) *PopupHandler { ) *PopupHandler {
return &PopupHandler{ return &PopupHandler{
Common: common, Common: common,
index: 0,
createPopupPanelFn: createPopupPanelFn, createPopupPanelFn: createPopupPanelFn,
onErrorFn: onErrorFn, onErrorFn: onErrorFn,
popContextFn: popContextFn, popContextFn: popContextFn,
@@ -93,10 +89,6 @@ func (self *PopupHandler) Error(err error) error {
} }
func (self *PopupHandler) ErrorMsg(message string) error { func (self *PopupHandler) ErrorMsg(message string) error {
self.Lock()
self.index++
self.Unlock()
// Need to set bold here explicitly; otherwise it gets cancelled by the red colouring. // 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(message))
if err := self.onErrorFn(); err != nil { if err := self.onErrorFn(); err != nil {
@@ -111,10 +103,6 @@ func (self *PopupHandler) Alert(title string, message string) error {
} }
func (self *PopupHandler) Confirm(opts types.ConfirmOpts) error { func (self *PopupHandler) Confirm(opts types.ConfirmOpts) error {
self.Lock()
self.index++
self.Unlock()
return self.createPopupPanelFn(context.Background(), types.CreatePopupPanelOpts{ return self.createPopupPanelFn(context.Background(), types.CreatePopupPanelOpts{
Title: opts.Title, Title: opts.Title,
Prompt: opts.Prompt, Prompt: opts.Prompt,
@@ -124,10 +112,6 @@ func (self *PopupHandler) Confirm(opts types.ConfirmOpts) error {
} }
func (self *PopupHandler) Prompt(opts types.PromptOpts) error { func (self *PopupHandler) Prompt(opts types.PromptOpts) error {
self.Lock()
self.index++
self.Unlock()
return self.createPopupPanelFn(context.Background(), types.CreatePopupPanelOpts{ return self.createPopupPanelFn(context.Background(), types.CreatePopupPanelOpts{
Title: opts.Title, Title: opts.Title,
Prompt: opts.InitialContent, Prompt: opts.InitialContent,