(text: string, start: number, end: number)
| 8 | // sliceAnsi may include a boundary-spanning wide char (e.g. CJK at position |
| 9 | // end-1 with width 2 overshoots by 1). Retry with a tighter bound once. |
| 10 | function sliceFit(text: string, start: number, end: number): string { |
| 11 | const s = sliceAnsi(text, start, end) |
| 12 | return stringWidth(s) > end - start ? sliceAnsi(text, start, end - 1) : s |
| 13 | } |
| 14 | |
| 15 | function truncate( |
| 16 | text: string, |