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

Method renderOption

internal/prompter/multi_select_with_search.go:351–368  ·  view source on GitHub ↗
(o msOption, cursor, selected bool)

Source from the content-addressed store, hash-verified

349}
350
351func (m *multiSelectSearchField) renderOption(o msOption, cursor, selected bool) string {
352 styles := m.activeStyles()
353
354 var parts []string
355 if cursor {
356 parts = append(parts, styles.MultiSelectSelector.String())
357 } else {
358 parts = append(parts, strings.Repeat(" ", lipgloss.Width(styles.MultiSelectSelector.String())))
359 }
360 if selected {
361 parts = append(parts, styles.SelectedPrefix.String())
362 parts = append(parts, styles.SelectedOption.Render(o.label))
363 } else {
364 parts = append(parts, styles.UnselectedPrefix.String())
365 parts = append(parts, styles.UnselectedOption.Render(o.label))
366 }
367 return lipgloss.JoinHorizontal(lipgloss.Left, parts...)
368}
369
370func (m *multiSelectSearchField) activeStyles() *huh.FieldStyles {
371 theme := m.theme

Callers 1

ViewMethod · 0.95

Calls 3

activeStylesMethod · 0.95
RenderMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected