MCPcopy Index your code
hub / github.com/coder/coder / viewableOptions

Method viewableOptions

cli/cliui/select.go:274–291  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

272}
273
274func (m selectModel) viewableOptions() ([]string, int) {
275 options := m.filteredOptions()
276 halfHeight := m.height / 2
277 bottom := 0
278 top := len(options)
279
280 switch {
281 case m.cursor <= halfHeight:
282 top = min(top, m.height)
283 case m.cursor < top-halfHeight:
284 bottom = max(0, m.cursor-halfHeight)
285 top = min(top, m.cursor+halfHeight+1)
286 default:
287 bottom = max(0, top-m.height)
288 }
289
290 return options[bottom:top], bottom
291}
292
293func (m selectModel) filteredOptions() []string {
294 options := []string{}

Callers 1

ViewMethod · 0.95

Calls 1

filteredOptionsMethod · 0.95

Tested by

no test coverage detected