From b413710d8c1ea475afdd03a1100846de89acbe58 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 15 Aug 2025 18:00:53 +0200 Subject: [PATCH] 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). --- docs/Config.md | 2 ++ pkg/config/user_config.go | 4 ++++ pkg/gui/controllers/menu_controller.go | 2 +- pkg/gui/controllers/suggestions_controller.go | 2 +- pkg/integration/components/menu_driver.go | 2 +- pkg/integration/components/prompt_driver.go | 4 ++-- schema/config.json | 8 ++++++++ 7 files changed, 19 insertions(+), 5 deletions(-) diff --git a/docs/Config.md b/docs/Config.md index 8c4d157c1..4bd589fe0 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -557,6 +557,8 @@ keybinding: select: goInto: confirm: + confirmMenu: + confirmSuggestion: confirmInEditor: confirmInEditor-alt: remove: d diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 66a5cddd3..c30d030ae 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -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: "", GoInto: "", Confirm: "", + ConfirmMenu: "", + ConfirmSuggestion: "", ConfirmInEditor: "", ConfirmInEditorAlt: "", Remove: "d", diff --git a/pkg/gui/controllers/menu_controller.go b/pkg/gui/controllers/menu_controller.go index 25d919f54..0465308df 100644 --- a/pkg/gui/controllers/menu_controller.go +++ b/pkg/gui/controllers/menu_controller.go @@ -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, diff --git a/pkg/gui/controllers/suggestions_controller.go b/pkg/gui/controllers/suggestions_controller.go index 01ec3a145..715ee12e9 100644 --- a/pkg/gui/controllers/suggestions_controller.go +++ b/pkg/gui/controllers/suggestions_controller.go @@ -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()), }, diff --git a/pkg/integration/components/menu_driver.go b/pkg/integration/components/menu_driver.go index eb7392d5a..95f29dcd3 100644 --- a/pkg/integration/components/menu_driver.go +++ b/pkg/integration/components/menu_driver.go @@ -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 } diff --git a/pkg/integration/components/prompt_driver.go b/pkg/integration/components/prompt_driver.go index 34c07614b..2c29dd7c4 100644 --- a/pkg/integration/components/prompt_driver.go +++ b/pkg/integration/components/prompt_driver.go @@ -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 { diff --git a/schema/config.json b/schema/config.json index 47d125e87..aa4e41012 100644 --- a/schema/config.json +++ b/schema/config.json @@ -1366,6 +1366,14 @@ "type": "string", "default": "\u003center\u003e" }, + "confirmMenu": { + "type": "string", + "default": "\u003center\u003e" + }, + "confirmSuggestion": { + "type": "string", + "default": "\u003center\u003e" + }, "confirmInEditor": { "type": "string", "default": "\u003ca-enter\u003e"