Skip to content

Commit 7c54c10

Browse files
committed
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).
1 parent 9660b4c commit 7c54c10

File tree

7 files changed

+19
-5
lines changed

7 files changed

+19
-5
lines changed

docs/Config.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,8 @@ keybinding:
557557
select: <space>
558558
goInto: <enter>
559559
confirm: <enter>
560+
confirmMenu: <enter>
561+
confirmSuggestion: <enter>
560562
confirmInEditor: <a-enter>
561563
confirmInEditor-alt: <c-s>
562564
remove: d

pkg/config/user_config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ type KeybindingUniversalConfig struct {
425425
Select string `yaml:"select"`
426426
GoInto string `yaml:"goInto"`
427427
Confirm string `yaml:"confirm"`
428+
ConfirmMenu string `yaml:"confirmMenu"`
429+
ConfirmSuggestion string `yaml:"confirmSuggestion"`
428430
ConfirmInEditor string `yaml:"confirmInEditor"`
429431
ConfirmInEditorAlt string `yaml:"confirmInEditor-alt"`
430432
Remove string `yaml:"remove"`
@@ -889,6 +891,8 @@ func GetDefaultConfig() *UserConfig {
889891
Select: "<space>",
890892
GoInto: "<enter>",
891893
Confirm: "<enter>",
894+
ConfirmMenu: "<enter>",
895+
ConfirmSuggestion: "<enter>",
892896
ConfirmInEditor: "<a-enter>",
893897
ConfirmInEditorAlt: "<c-s>",
894898
Remove: "d",

pkg/gui/controllers/menu_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (self *MenuController) GetKeybindings(opts types.KeybindingsOpts) []*types.
3838
GetDisabledReason: self.require(self.singleItemSelected()),
3939
},
4040
{
41-
Key: opts.GetKey(opts.Config.Universal.Confirm),
41+
Key: opts.GetKey(opts.Config.Universal.ConfirmMenu),
4242
Handler: self.withItem(self.press),
4343
GetDisabledReason: self.require(self.singleItemSelected()),
4444
Description: self.c.Tr.Execute,

pkg/gui/controllers/suggestions_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewSuggestionsController(
3232
func (self *SuggestionsController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding {
3333
bindings := []*types.Binding{
3434
{
35-
Key: opts.GetKey(opts.Config.Universal.Confirm),
35+
Key: opts.GetKey(opts.Config.Universal.ConfirmSuggestion),
3636
Handler: func() error { return self.context().State.OnConfirm() },
3737
GetDisabledReason: self.require(self.singleItemSelected()),
3838
},

pkg/integration/components/menu_driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (self *MenuDriver) Title(expected *TextMatcher) *MenuDriver {
2121
func (self *MenuDriver) Confirm() *MenuDriver {
2222
self.checkNecessaryChecksCompleted()
2323

24-
self.getViewDriver().PressEnter()
24+
self.getViewDriver().Press(self.t.keys.Universal.ConfirmMenu)
2525

2626
return self
2727
}

pkg/integration/components/prompt_driver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ func (self *PromptDriver) ConfirmFirstSuggestion() {
7272
self.t.Views().Suggestions().
7373
IsFocused().
7474
SelectedLineIdx(0).
75-
PressEnter()
75+
Press(self.t.keys.Universal.ConfirmSuggestion)
7676
}
7777

7878
func (self *PromptDriver) ConfirmSuggestion(matcher *TextMatcher) {
7979
self.t.press(self.t.keys.Universal.TogglePanel)
8080
self.t.Views().Suggestions().
8181
IsFocused().
8282
NavigateToLine(matcher).
83-
PressEnter()
83+
Press(self.t.keys.Universal.ConfirmSuggestion)
8484
}
8585

8686
func (self *PromptDriver) DeleteSuggestion(matcher *TextMatcher) *PromptDriver {

schema/config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,14 @@
13661366
"type": "string",
13671367
"default": "\u003center\u003e"
13681368
},
1369+
"confirmMenu": {
1370+
"type": "string",
1371+
"default": "\u003center\u003e"
1372+
},
1373+
"confirmSuggestion": {
1374+
"type": "string",
1375+
"default": "\u003center\u003e"
1376+
},
13691377
"confirmInEditor": {
13701378
"type": "string",
13711379
"default": "\u003ca-enter\u003e"

0 commit comments

Comments
 (0)