MCPcopy Index your code
hub / github.com/cli/cli / updateSelect

Method updateSelect

internal/prompter/multi_select_with_search.go:276–311  ·  view source on GitHub ↗
(msg tea.KeyPressMsg)

Source from the content-addressed store, hash-verified

274}
275
276func (m *multiSelectSearchField) updateSelect(msg tea.KeyPressMsg) (huh.Model, tea.Cmd) {
277 switch {
278 case key.Matches(msg, key.NewBinding(key.WithKeys("shift+tab"))):
279 // Back to search mode.
280 m.mode = msModeSearch
281 m.search.Focus()
282 return m, nil
283
284 case key.Matches(msg, key.NewBinding(key.WithKeys("enter"))):
285 return m, huh.NextField
286
287 case key.Matches(msg, key.NewBinding(key.WithKeys("up", "k"))):
288 if m.cursor > 0 {
289 m.cursor--
290 }
291 return m, nil
292
293 case key.Matches(msg, key.NewBinding(key.WithKeys("down", "j"))):
294 if m.cursor < len(m.options)-1 {
295 m.cursor++
296 }
297 return m, nil
298
299 case key.Matches(msg, key.NewBinding(key.WithKeys("space", "x"))):
300 if len(m.options) > 0 {
301 k := m.options[m.cursor].value
302 m.selected[k] = !m.selected[k]
303 if !m.selected[k] {
304 delete(m.selected, k)
305 }
306 }
307 return m, nil
308 }
309
310 return m, nil
311}
312
313func (m *multiSelectSearchField) View() string {
314 styles := m.activeStyles()

Callers 1

UpdateMethod · 0.95

Calls 2

MatchesMethod · 0.80
FocusMethod · 0.45

Tested by

no test coverage detected