Commit 5337518
committed
fix: account for visual line wrapping when erasing terminal output on resize
When the terminal is resized narrower, previously rendered lines soft-wrap
to occupy more visual rows than the logical line count tracks. This causes
eraseLines to under-erase, leaving ghost/stale lines at the top of the output.
The fix introduces visual row counting that uses stringWidth to measure each
line's visible width and Math.ceil(width / columns) to compute the actual
terminal rows occupied after wrapping. This is applied in three places:
- The standard render path in log-update now computes visual rows from
previousOutput at the current terminal width when erasing
- A new clearWithWrapping() method on LogUpdate uses the same calculation
for resize-triggered clears
- The resize handler in Ink flushes pending throttled writes before clearing,
ensuring previousOutput reflects what's actually on screen
Fixes vadimdemedes#9071 parent d856a6c commit 5337518
2 files changed
Lines changed: 89 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
457 | | - | |
458 | | - | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
459 | 469 | | |
460 | 470 | | |
461 | 471 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
31 | 58 | | |
32 | 59 | | |
33 | 60 | | |
| |||
86 | 113 | | |
87 | 114 | | |
88 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
89 | 121 | | |
90 | 122 | | |
91 | 123 | | |
92 | | - | |
| 124 | + | |
93 | 125 | | |
94 | 126 | | |
95 | 127 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 128 | + | |
100 | 129 | | |
101 | 130 | | |
102 | 131 | | |
| |||
119 | 148 | | |
120 | 149 | | |
121 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
122 | 169 | | |
123 | 170 | | |
124 | 171 | | |
| |||
233 | 280 | | |
234 | 281 | | |
235 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
236 | 288 | | |
237 | 289 | | |
238 | | - | |
| 290 | + | |
239 | 291 | | |
240 | 292 | | |
241 | 293 | | |
242 | 294 | | |
243 | 295 | | |
244 | 296 | | |
245 | 297 | | |
246 | | - | |
| 298 | + | |
247 | 299 | | |
248 | 300 | | |
249 | 301 | | |
| |||
322 | 374 | | |
323 | 375 | | |
324 | 376 | | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
325 | 395 | | |
326 | 396 | | |
327 | 397 | | |
| |||
0 commit comments