Skip to content

Commit

Permalink
Remove loader code for confirmation panel
Browse files Browse the repository at this point in the history
It wasn't being used and if it were to be used, there would be a memory
leak
  • Loading branch information
jesseduffield committed May 26, 2024
1 parent 968b09e commit cdf1d9a
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions pkg/gui/confirmation_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package gui

import (
"context"
"strings"

"github.com/fatih/color"
Expand Down Expand Up @@ -65,25 +64,21 @@ func (gui *Gui) getConfirmationPanelDimensions(wrap bool, prompt string) (int, i

func (gui *Gui) createPromptPanel(title string, handleConfirm func(*gocui.Gui, *gocui.View) error) error {
gui.onNewPopupPanel()
err := gui.prepareConfirmationPanel(title, "", false)
err := gui.prepareConfirmationPanel(title, "")
if err != nil {
return err
}
gui.Views.Confirmation.Editable = true
return gui.setKeyBindings(gui.g, handleConfirm, nil)
}

func (gui *Gui) prepareConfirmationPanel(title, prompt string, hasLoader bool) error {
func (gui *Gui) prepareConfirmationPanel(title, prompt string) error {
x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(true, prompt)
confirmationView := gui.Views.Confirmation
_, err := gui.g.SetView("confirmation", x0, y0, x1, y1, 0)
if err != nil {
return err
}
confirmationView.HasLoader = hasLoader
if hasLoader {
gui.g.StartTicking(context.Background()) // TODO cancel this
}
confirmationView.Title = title
confirmationView.Visible = true
gui.g.Update(func(g *gocui.Gui) error {
Expand All @@ -101,18 +96,18 @@ func (gui *Gui) onNewPopupPanel() {
// The golangcilint unparam linter complains that handleClose is alwans nil but one day it won't be nil.
// nolint:unparam
func (gui *Gui) createConfirmationPanel(title, prompt string, handleConfirm, handleClose func(*gocui.Gui, *gocui.View) error) error {
return gui.createPopupPanel(title, prompt, false, handleConfirm, handleClose)
return gui.createPopupPanel(title, prompt, handleConfirm, handleClose)
}

func (gui *Gui) createPopupPanel(title, prompt string, hasLoader bool, handleConfirm, handleClose func(*gocui.Gui, *gocui.View) error) error {
func (gui *Gui) createPopupPanel(title, prompt string, handleConfirm, handleClose func(*gocui.Gui, *gocui.View) error) error {
gui.onNewPopupPanel()
gui.g.Update(func(g *gocui.Gui) error {
if gui.currentViewName() == "confirmation" {
if err := gui.closeConfirmationPrompt(); err != nil {
gui.Log.Error(err.Error())
}
}
err := gui.prepareConfirmationPanel(title, prompt, hasLoader)
err := gui.prepareConfirmationPanel(title, prompt)
if err != nil {
return err
}
Expand Down

0 comments on commit cdf1d9a

Please sign in to comment.