diff --git a/cli/cliui/select.go b/cli/cliui/select.go index f609ca81c3..8ef4c0e4ba 100644 --- a/cli/cliui/select.go +++ b/cli/cliui/select.go @@ -491,6 +491,11 @@ func (m multiSelectModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeySpace: options := m.filteredOptions() + + if m.enableCustomInput && m.cursor == len(options) { + return m, nil + } + if len(options) != 0 { options[m.cursor].chosen = !options[m.cursor].chosen } diff --git a/cli/exp_prompts.go b/cli/exp_prompts.go index ef51a1ce04..a100068f22 100644 --- a/cli/exp_prompts.go +++ b/cli/exp_prompts.go @@ -174,6 +174,19 @@ func (RootCmd) promptExample() *serpent.Command { _, _ = fmt.Fprintf(inv.Stdout, "%q are nice choices.\n", strings.Join(multiSelectValues, ", ")) return multiSelectError }, useThingsOption, enableCustomInputOption), + promptCmd("multi-select-no-defaults", func(inv *serpent.Invocation) error { + if len(multiSelectValues) == 0 { + multiSelectValues, multiSelectError = cliui.MultiSelect(inv, cliui.MultiSelectOptions{ + Message: "Select some things:", + Options: []string{ + "Code", "Chairs", "Whale", + }, + EnableCustomInput: enableCustomInput, + }) + } + _, _ = fmt.Fprintf(inv.Stdout, "%q are nice choices.\n", strings.Join(multiSelectValues, ", ")) + return multiSelectError + }, useThingsOption, enableCustomInputOption), promptCmd("rich-multi-select", func(inv *serpent.Invocation) error { if len(multiSelectValues) == 0 { multiSelectValues, multiSelectError = cliui.MultiSelect(inv, cliui.MultiSelectOptions{