MCPcopy
hub / github.com/cli/cli / multiSelectSearchField

Struct multiSelectSearchField

internal/prompter/multi_select_with_search.go:20–50  ·  view source on GitHub ↗

multiSelectSearchField is a custom huh Field that combines a text input for searching with a multi-select list. Unlike huh's built-in OptionsFunc, search results are loaded synchronously when the user presses Enter in the search input, avoiding goroutine races with selection state.

Source from the content-addressed store, hash-verified

18// search results are loaded synchronously when the user presses Enter in
19// the search input, avoiding goroutine races with selection state.
20type multiSelectSearchField struct {
21 // configuration
22 title string
23 searchTitle string
24 searchFunc func(string) MultiSelectSearchResult
25
26 // state
27 mode msMode // which sub-component has focus
28 search textinput.Model
29 cursor int
30 loading bool
31 spinner spinner.Model
32
33 // options and selections
34 options []msOption
35 selected map[string]bool // key → selected (source of truth)
36 optionLabels map[string]string // key → display label
37 lastQuery string
38 defaultValues []string
39 persistent []string
40
41 // field metadata
42 key string
43 err error
44 focused bool
45 width int
46 height int
47 theme huh.Theme
48 hasDarkBg bool
49 position huh.FieldPosition
50}
51
52type msMode int
53

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected