Commit c21e3f6
committed
Use ratatui's line_count for exact wrapped-row count
v0.1.1's max_scroll used ceil(display_width / width) per Line to
estimate wrapped rows, but ratatui's WordWrapper can exceed that
ceiling: with trim: false, a short trailing word forces the next
word to the next row while leaving whitespace on the previous row,
producing more rows than a naive division.
Concrete case: "one two three four five six seven eight" at W=10
word-wraps to 5 rows, but ceil(39/10) = 4. Our estimate was one row
short — exactly the bug the user saw after v0.1.1.
Defer to ratatui by enabling its unstable-rendered-line-info feature
and calling Paragraph::line_count(width), which runs the same
WordWrapper the renderer uses. Counts are authoritative.
Add a regression test that captures the word-boundary case ratatui
exceeds the ceiling on; correct the previous "hello world" at W=4
assertion to the 4 rows ratatui actually produces.1 parent 52811c6 commit c21e3f6
3 files changed
Lines changed: 16 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
27 | 18 | | |
28 | 19 | | |
29 | 20 | | |
| |||
95 | 86 | | |
96 | 87 | | |
97 | 88 | | |
98 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
99 | 98 | | |
100 | 99 | | |
101 | 100 | | |
| |||
0 commit comments