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

Method View

internal/prompter/multi_select_with_search.go:313–349  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

311}
312
313func (m *multiSelectSearchField) View() string {
314 styles := m.activeStyles()
315 var sb strings.Builder
316
317 // Title.
318 if m.title != "" {
319 sb.WriteString(styles.Title.Render(m.title))
320 sb.WriteString("\n")
321 }
322
323 // Search input.
324 if m.searchTitle != "" {
325 sb.WriteString(styles.Description.Render(m.searchTitle))
326 sb.WriteString("\n")
327 }
328 sb.WriteString(m.search.View())
329 sb.WriteString("\n")
330
331 // Options list.
332 if m.loading {
333 m.spinner.Style = styles.MultiSelectSelector.UnsetString()
334 sb.WriteString(m.spinner.View() + " Loading...")
335 sb.WriteString("\n")
336 } else if len(m.options) == 0 {
337 sb.WriteString(styles.UnselectedOption.Render(" No results"))
338 sb.WriteString("\n")
339 } else {
340 for i, o := range m.options {
341 cursor := m.mode == msModeSelect && i == m.cursor
342 isSelected := m.selected[o.value]
343 sb.WriteString(m.renderOption(o, cursor, isSelected))
344 sb.WriteString("\n")
345 }
346 }
347
348 return styles.Base.Width(m.width).Height(m.height).Render(sb.String())
349}
350
351func (m *multiSelectSearchField) renderOption(o msOption, cursor, selected bool) string {
352 styles := m.activeStyles()

Callers

nothing calls this directly

Calls 5

activeStylesMethod · 0.95
renderOptionMethod · 0.95
RenderMethod · 0.65
ViewMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected