Commit eb8f5e9
committed
fix: clamp ANSI-aware padding in buildColored to prevent RangeError
String.repeat() throws when given a negative count. The pad helper was
computing innerWidth - 2 - s.length on strings that already contained
ANSI escape codes, so the invisible bytes inflated s.length past the
box width. Strip ANSI codes via a regex before measuring visible length
and add Math.max(0, …) as a safety guard.1 parent 83da9db commit eb8f5e9
1 file changed
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | | - | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
| |||
0 commit comments