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)
| 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. |
| 18 | func 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 | } |
nothing calls this directly
no test coverage detected