From 21dd901bd9827d60b0941b1781cc3c1b30496c56 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 10 Jul 2025 18:06:41 +0200 Subject: [PATCH] Extract helper function --- .../controllers/confirmation_controller.go | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/pkg/gui/controllers/confirmation_controller.go b/pkg/gui/controllers/confirmation_controller.go index 6bfff6b98..f121bb0f1 100644 --- a/pkg/gui/controllers/confirmation_controller.go +++ b/pkg/gui/controllers/confirmation_controller.go @@ -41,15 +41,7 @@ func (self *ConfirmationController) GetKeybindings(opts types.KeybindingsOpts) [ Key: opts.GetKey(opts.Config.Universal.TogglePanel), Handler: func() error { if len(self.c.Contexts().Suggestions.State.Suggestions) > 0 { - subtitle := "" - if self.c.State().GetRepoState().GetCurrentPopupOpts().HandleDeleteSuggestion != nil { - // We assume that whenever things are deletable, they - // are also editable, so we show both keybindings - subtitle = fmt.Sprintf(self.c.Tr.SuggestionsSubtitle, - self.c.UserConfig().Keybinding.Universal.Remove, self.c.UserConfig().Keybinding.Universal.Edit) - } - self.c.Views().Suggestions.Subtitle = subtitle - self.c.Context().Replace(self.c.Contexts().Suggestions) + self.switchToSuggestions() } return nil }, @@ -72,3 +64,15 @@ func (self *ConfirmationController) Context() types.Context { func (self *ConfirmationController) context() *context.ConfirmationContext { return self.c.Contexts().Confirmation } + +func (self *ConfirmationController) switchToSuggestions() { + subtitle := "" + if self.c.State().GetRepoState().GetCurrentPopupOpts().HandleDeleteSuggestion != nil { + // We assume that whenever things are deletable, they + // are also editable, so we show both keybindings + subtitle = fmt.Sprintf(self.c.Tr.SuggestionsSubtitle, + self.c.UserConfig().Keybinding.Universal.Remove, self.c.UserConfig().Keybinding.Universal.Edit) + } + self.c.Views().Suggestions.Subtitle = subtitle + self.c.Context().Replace(self.c.Contexts().Suggestions) +}