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

Method updateSelect

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

Source from the content-addressed store, hash-verified

262}
263
264func (m *multiSelectSearchField) updateSelect(msg tea.KeyPressMsg) (huh.Model, tea.Cmd) {
265 switch {
266 case key.Matches(msg, key.NewBinding(key.WithKeys("shift+tab"))):
267 // Back to search mode.
268 m.mode = msModeSearch
269 m.search.Focus()
270 return m, nil
271
272 case key.Matches(msg, key.NewBinding(key.WithKeys("enter"))):
273 return m, huh.NextField
274
275 case key.Matches(msg, key.NewBinding(key.WithKeys("up", "k"))):
276 if m.cursor > 0 {
277 m.cursor--
278 }
279 return m, nil
280
281 case key.Matches(msg, key.NewBinding(key.WithKeys("down", "j"))):
282 if m.cursor < len(m.options)-1 {
283 m.cursor++
284 }
285 return m, nil
286
287 case key.Matches(msg, key.NewBinding(key.WithKeys("space", "x"))):
288 if len(m.options) > 0 {
289 k := m.options[m.cursor].value
290 m.selected[k] = !m.selected[k]
291 if !m.selected[k] {
292 delete(m.selected, k)
293 }
294 }
295 return m, nil
296 }
297
298 return m, nil
299}
300
301func (m *multiSelectSearchField) View() string {
302 styles := m.activeStyles()

Callers 1

UpdateMethod · 0.95

Calls 2

MatchesMethod · 0.80
FocusMethod · 0.45

Tested by

no test coverage detected