Skip to content

Commit cb001ff

Browse files
committed
fixup! feat: support custom keybinds in custom command prompt menus
1 parent d7a787f commit cb001ff

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

pkg/config/user_config_validation.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ func validateCustomCommands(customCommands []CustomCommand) error {
136136
return err
137137
}
138138
} else {
139+
for _, prompt := range customCommand.Prompts {
140+
if err := validateCustomCommandPrompt(prompt); err != nil {
141+
return err
142+
}
143+
}
144+
139145
if err := validateEnum("customCommand.output", customCommand.Output,
140146
[]string{"", "none", "terminal", "log", "logWithPty", "popup"}); err != nil {
141147
return err
@@ -144,3 +150,13 @@ func validateCustomCommands(customCommands []CustomCommand) error {
144150
}
145151
return nil
146152
}
153+
154+
func validateCustomCommandPrompt(prompt CustomCommandPrompt) error {
155+
for _, option := range prompt.Options {
156+
if !isValidKeybindingKey(option.Key) {
157+
return fmt.Errorf("Unexpected prompt option keybind: %s", option.Key)
158+
}
159+
}
160+
161+
return nil
162+
}

pkg/config/user_config_validation_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,31 @@ func TestUserConfigValidate_enums(t *testing.T) {
176176
{value: "invalid_value", valid: false},
177177
},
178178
},
179+
{
180+
name: "Custom command keybinding in prompt menu",
181+
setup: func(config *UserConfig, value string) {
182+
config.CustomCommands = []CustomCommand{
183+
{
184+
Key: "X",
185+
Description: "My Custom Commands",
186+
Prompts: []CustomCommandPrompt{
187+
{
188+
Options: []CustomCommandMenuOption{
189+
{Key: value},
190+
},
191+
},
192+
},
193+
},
194+
}
195+
},
196+
testCases: []testCase{
197+
{value: "", valid: true},
198+
{value: "<disabled>", valid: true},
199+
{value: "q", valid: true},
200+
{value: "<c-c>", valid: true},
201+
{value: "invalid_value", valid: false},
202+
},
203+
},
179204
{
180205
name: "Custom command output",
181206
setup: func(config *UserConfig, value string) {

0 commit comments

Comments
 (0)