Skip to content

Commit 21dd901

Browse files
committed
Extract helper function
1 parent 8ad2637 commit 21dd901

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

pkg/gui/controllers/confirmation_controller.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,7 @@ func (self *ConfirmationController) GetKeybindings(opts types.KeybindingsOpts) [
4141
Key: opts.GetKey(opts.Config.Universal.TogglePanel),
4242
Handler: func() error {
4343
if len(self.c.Contexts().Suggestions.State.Suggestions) > 0 {
44-
subtitle := ""
45-
if self.c.State().GetRepoState().GetCurrentPopupOpts().HandleDeleteSuggestion != nil {
46-
// We assume that whenever things are deletable, they
47-
// are also editable, so we show both keybindings
48-
subtitle = fmt.Sprintf(self.c.Tr.SuggestionsSubtitle,
49-
self.c.UserConfig().Keybinding.Universal.Remove, self.c.UserConfig().Keybinding.Universal.Edit)
50-
}
51-
self.c.Views().Suggestions.Subtitle = subtitle
52-
self.c.Context().Replace(self.c.Contexts().Suggestions)
44+
self.switchToSuggestions()
5345
}
5446
return nil
5547
},
@@ -72,3 +64,15 @@ func (self *ConfirmationController) Context() types.Context {
7264
func (self *ConfirmationController) context() *context.ConfirmationContext {
7365
return self.c.Contexts().Confirmation
7466
}
67+
68+
func (self *ConfirmationController) switchToSuggestions() {
69+
subtitle := ""
70+
if self.c.State().GetRepoState().GetCurrentPopupOpts().HandleDeleteSuggestion != nil {
71+
// We assume that whenever things are deletable, they
72+
// are also editable, so we show both keybindings
73+
subtitle = fmt.Sprintf(self.c.Tr.SuggestionsSubtitle,
74+
self.c.UserConfig().Keybinding.Universal.Remove, self.c.UserConfig().Keybinding.Universal.Edit)
75+
}
76+
self.c.Views().Suggestions.Subtitle = subtitle
77+
self.c.Context().Replace(self.c.Contexts().Suggestions)
78+
}

0 commit comments

Comments
 (0)