MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestWrapForScrollbackCapsEveryLineToWidth

Function TestWrapForScrollbackCapsEveryLineToWidth

internal/tui/render_test.go:15–23  ·  view source on GitHub ↗

A prompt echo (or any content line) wider than the terminal must be wrapped before it reaches tea.Println: bubbletea dumps queued Println lines verbatim, so an over-width line soft-wraps in the terminal into rows the renderer never counted, drifting its cursor math and leaving a duplicated prompt fr

(t *testing.T)

Source from the content-addressed store, hash-verified

13// A prompt echo (or any content line) wider than the terminal must be wrapped
14// before it reaches tea.Println: bubbletea dumps queued Println lines verbatim,
15// so an over-width line soft-wraps in the terminal into rows the renderer never
16// counted, drifting its cursor math and leaving a duplicated prompt fragment on
17// screen. wrapForScrollback is the guard; every emitted line must fit the width.
18func TestWrapForScrollbackCapsEveryLineToWidth(t *testing.T) {
19 const width = 80
20 longEcho := stylePrompt.Render("▌ ") + styleUser.Render(strings.Repeat("word ", 60))
21 for line := range strings.SplitSeq(wrapForScrollback(longEcho, width), "\n") {
22 if w := ansi.StringWidth(line); w > width {
23 t.Fatalf("wrapped line width %d exceeds terminal width %d: %q", w, width, line)
24 }
25 }
26}

Callers

nothing calls this directly

Calls 1

wrapForScrollbackFunction · 0.85

Tested by

no test coverage detected