mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
Extract helper function
This commit is contained in:
@ -41,15 +41,7 @@ func (self *ConfirmationController) GetKeybindings(opts types.KeybindingsOpts) [
|
|||||||
Key: opts.GetKey(opts.Config.Universal.TogglePanel),
|
Key: opts.GetKey(opts.Config.Universal.TogglePanel),
|
||||||
Handler: func() error {
|
Handler: func() error {
|
||||||
if len(self.c.Contexts().Suggestions.State.Suggestions) > 0 {
|
if len(self.c.Contexts().Suggestions.State.Suggestions) > 0 {
|
||||||
subtitle := ""
|
self.switchToSuggestions()
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@ -72,3 +64,15 @@ func (self *ConfirmationController) Context() types.Context {
|
|||||||
func (self *ConfirmationController) context() *context.ConfirmationContext {
|
func (self *ConfirmationController) context() *context.ConfirmationContext {
|
||||||
return self.c.Contexts().Confirmation
|
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)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user