MCPcopy Create free account
hub / github.com/codehamr/codehamr / countCmdLeaves

Function countCmdLeaves

internal/tui/resize_test.go:218–239  ·  view source on GitHub ↗

countCmdLeaves runs cmd, recurses into the slice-shaped []tea.Cmd payload of tea.BatchMsg / tea.sequenceMsg (both unexported), and counts leaves where match holds, asserting what a Sequence emits without importing bubbletea's internal types.

(cmd tea.Cmd, match func(tea.Cmd, tea.Msg) bool)

Source from the content-addressed store, hash-verified

216// where match holds, asserting what a Sequence emits without importing
217// bubbletea's internal types.
218func countCmdLeaves(cmd tea.Cmd, match func(tea.Cmd, tea.Msg) bool) int {
219 if cmd == nil {
220 return 0
221 }
222 msg := cmd()
223 if match(cmd, msg) {
224 return 1
225 }
226 rv := reflect.ValueOf(msg)
227 if rv.Kind() != reflect.Slice {
228 return 0
229 }
230 n := 0
231 for i := 0; i < rv.Len(); i++ {
232 c, ok := rv.Index(i).Interface().(tea.Cmd)
233 if !ok {
234 continue
235 }
236 n += countCmdLeaves(c, match)
237 }
238 return n
239}
240
241func cmdYieldsClearScreen(cmd tea.Cmd) bool {
242 target := reflect.TypeOf(tea.ClearScreen())

Callers 3

cmdYieldsClearScreenFunction · 0.85
cmdYieldsScrollbackEraseFunction · 0.85
countPrintlnLeavesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected