diff options
Diffstat (limited to 'pkg/gui/confirmation_panel.go')
-rw-r--r-- | pkg/gui/confirmation_panel.go | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go index 19f8745a8..4177a689b 100644 --- a/pkg/gui/confirmation_panel.go +++ b/pkg/gui/confirmation_panel.go @@ -16,9 +16,9 @@ import ( // This file is for the rendering of confirmation panels along with setting and handling associated // keybindings. -func (gui *Gui) wrappedConfirmationFunction(handlersManageFocus bool, function func() error) func() error { +func (gui *Gui) wrappedConfirmationFunction(function func() error) func() error { return func() error { - if err := gui.closeConfirmationPrompt(handlersManageFocus); err != nil { + if err := gui.c.PopContext(); err != nil { return err } @@ -32,9 +32,9 @@ func (gui *Gui) wrappedConfirmationFunction(handlersManageFocus bool, function f } } -func (gui *Gui) wrappedPromptConfirmationFunction(handlersManageFocus bool, function func(string) error, getResponse func() string) func() error { +func (gui *Gui) wrappedPromptConfirmationFunction(function func(string) error, getResponse func() string) func() error { return func() error { - if err := gui.closeConfirmationPrompt(handlersManageFocus); err != nil { + if err := gui.c.PopContext(); err != nil { return err } @@ -48,27 +48,15 @@ func (gui *Gui) wrappedPromptConfirmationFunction(handlersManageFocus bool, func } } -func (gui *Gui) closeConfirmationPrompt(handlersManageFocus bool) error { +func (gui *Gui) deactivateConfirmationPrompt() { gui.Mutexes.PopupMutex.Lock() gui.State.CurrentPopupOpts = nil gui.Mutexes.PopupMutex.Unlock() - // we've already closed it so we can just return - if !gui.Views.Confirmation.Visible { - return nil - } - - if !handlersManageFocus { - if err := gui.c.PopContext(); err != nil { - return err - } - } - - gui.clearConfirmationViewKeyBindings() gui.Views.Confirmation.Visible = false gui.Views.Suggestions.Visible = false - return nil + gui.clearConfirmationViewKeyBindings() } func (gui *Gui) getMessageHeight(wrap bool, message string, width int) int { @@ -219,14 +207,13 @@ func (gui *Gui) setKeyBindings(opts types.CreatePopupPanelOpts) error { _ = gui.renderString(gui.Views.Options, actions) var onConfirm func() error if opts.HandleConfirmPrompt != nil { - onConfirm = gui.wrappedPromptConfirmationFunction(opts.HandlersManageFocus, opts.HandleConfirmPrompt, func() string { return gui.Views.Confirmation.TextArea.GetContent() }) + onConfirm = gui.wrappedPromptConfirmationFunction(opts.HandleConfirmPrompt, func() string { return gui.Views.Confirmation.TextArea.GetContent() }) } else { - onConfirm = gui.wrappedConfirmationFunction(opts.HandlersManageFocus, opts.HandleConfirm) + onConfirm = gui.wrappedConfirmationFunction(opts.HandleConfirm) } keybindingConfig := gui.c.UserConfig.Keybinding onSuggestionConfirm := gui.wrappedPromptConfirmationFunction( - opts.HandlersManageFocus, opts.HandleConfirmPrompt, gui.getSelectedSuggestionValue, ) @@ -248,7 +235,7 @@ func (gui *Gui) setKeyBindings(opts types.CreatePopupPanelOpts) error { ViewName: "confirmation", Contexts: []string{string(context.CONFIRMATION_CONTEXT_KEY)}, Key: gui.getKey(keybindingConfig.Universal.Return), - Handler: gui.wrappedConfirmationFunction(opts.HandlersManageFocus, opts.HandleClose), + Handler: gui.wrappedConfirmationFunction(opts.HandleClose), }, { ViewName: "confirmation", @@ -277,7 +264,7 @@ func (gui *Gui) setKeyBindings(opts types.CreatePopupPanelOpts) error { ViewName: "suggestions", Contexts: []string{string(context.SUGGESTIONS_CONTEXT_KEY)}, Key: gui.getKey(keybindingConfig.Universal.Return), - Handler: gui.wrappedConfirmationFunction(opts.HandlersManageFocus, opts.HandleClose), + Handler: gui.wrappedConfirmationFunction(opts.HandleClose), }, { ViewName: "suggestions", |