1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-09-16 09:16:26 +02:00

Add separate keybindings for confirmMenu and confirmSuggestion

It seems useful to have the flexibility to remap "enter" in confirmations to
"y", but keep "enter" for menus and suggestions (even though we sometimes use
menus as confirmations, but it's still good to give users the choice).
This commit is contained in:
Stefan Haller
2025-08-15 18:00:53 +02:00
parent 81868de264
commit b413710d8c
7 changed files with 19 additions and 5 deletions

View File

@@ -425,6 +425,8 @@ type KeybindingUniversalConfig struct {
Select string `yaml:"select"`
GoInto string `yaml:"goInto"`
Confirm string `yaml:"confirm"`
ConfirmMenu string `yaml:"confirmMenu"`
ConfirmSuggestion string `yaml:"confirmSuggestion"`
ConfirmInEditor string `yaml:"confirmInEditor"`
ConfirmInEditorAlt string `yaml:"confirmInEditor-alt"`
Remove string `yaml:"remove"`
@@ -889,6 +891,8 @@ func GetDefaultConfig() *UserConfig {
Select: "<space>",
GoInto: "<enter>",
Confirm: "<enter>",
ConfirmMenu: "<enter>",
ConfirmSuggestion: "<enter>",
ConfirmInEditor: "<a-enter>",
ConfirmInEditorAlt: "<c-s>",
Remove: "d",

View File

@@ -38,7 +38,7 @@ func (self *MenuController) GetKeybindings(opts types.KeybindingsOpts) []*types.
GetDisabledReason: self.require(self.singleItemSelected()),
},
{
Key: opts.GetKey(opts.Config.Universal.Confirm),
Key: opts.GetKey(opts.Config.Universal.ConfirmMenu),
Handler: self.withItem(self.press),
GetDisabledReason: self.require(self.singleItemSelected()),
Description: self.c.Tr.Execute,

View File

@@ -32,7 +32,7 @@ func NewSuggestionsController(
func (self *SuggestionsController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding {
bindings := []*types.Binding{
{
Key: opts.GetKey(opts.Config.Universal.Confirm),
Key: opts.GetKey(opts.Config.Universal.ConfirmSuggestion),
Handler: func() error { return self.context().State.OnConfirm() },
GetDisabledReason: self.require(self.singleItemSelected()),
},

View File

@@ -21,7 +21,7 @@ func (self *MenuDriver) Title(expected *TextMatcher) *MenuDriver {
func (self *MenuDriver) Confirm() *MenuDriver {
self.checkNecessaryChecksCompleted()
self.getViewDriver().PressEnter()
self.getViewDriver().Press(self.t.keys.Universal.ConfirmMenu)
return self
}

View File

@@ -72,7 +72,7 @@ func (self *PromptDriver) ConfirmFirstSuggestion() {
self.t.Views().Suggestions().
IsFocused().
SelectedLineIdx(0).
PressEnter()
Press(self.t.keys.Universal.ConfirmSuggestion)
}
func (self *PromptDriver) ConfirmSuggestion(matcher *TextMatcher) {
@@ -80,7 +80,7 @@ func (self *PromptDriver) ConfirmSuggestion(matcher *TextMatcher) {
self.t.Views().Suggestions().
IsFocused().
NavigateToLine(matcher).
PressEnter()
Press(self.t.keys.Universal.ConfirmSuggestion)
}
func (self *PromptDriver) DeleteSuggestion(matcher *TextMatcher) *PromptDriver {