TestPromptShrinksAfterSubmit: after Enter submits a multi-line prompt the textarea resets to empty and the height snaps back to 1 line.
(t *testing.T)
| 2411 | // width=100, effective=96. Two short logical lines = 2 visual rows. |
| 2412 | m.ta.SetValue("first line\nsecond line") |
| 2413 | if got := m.visualPromptLines(); got != 2 { |
| 2414 | t.Errorf("two short lines should produce 2 visual rows, got %d", got) |
| 2415 | } |
| 2416 | // One line that wraps to multiple visual rows. |
| 2417 | m.ta.SetValue(strings.Repeat("x", 200)) |
| 2418 | if got := m.visualPromptLines(); got < 2 { |
| 2419 | t.Errorf("200-char line should wrap past 1 row, got %d", got) |
| 2420 | } |
| 2421 | } |
| 2422 | |
| 2423 | // TestPromptGrowsOnWrappedLongLine: a long paragraph typed without Enter has |
| 2424 | // LineCount()==1, so relying on it sticks the textarea at 1 row while text wraps |
| 2425 | // off-screen. recomputeLayout must count *visual* rows. |
| 2426 | func TestPromptGrowsOnWrappedLongLine(t *testing.T) { |
| 2427 | m := newTestModel(t, func(http.ResponseWriter, *http.Request) {}) |
| 2428 | // newTestModel sets width=100 → effective text width ~96. 300 runes of |
| 2429 | // text wraps to 4 rows (ceil(300/96)). |
| 2430 | m.ta.SetValue(strings.Repeat("x", 300)) |
| 2431 | m.recomputeLayout() |
| 2432 | if got := m.ta.Height(); got < 2 { |
| 2433 | t.Fatalf("long wrapped line should expand textarea past 1 row, got %d", got) |
nothing calls this directly
no test coverage detected