(text: string, start: number, end: number)
| 21 | // sliceAnsi may include a boundary-spanning wide char (e.g. CJK at position |
| 22 | // end-1 with width 2 overshoots by 1). Retry with a tighter bound once. |
| 23 | function sliceFit(text: string, start: number, end: number): string { |
| 24 | const s = sliceAnsi(text, start, end) |
| 25 | return stringWidth(s) > end - start ? sliceAnsi(text, start, end - 1) : s |
| 26 | } |
| 27 | |
| 28 | function truncate( |
| 29 | text: string, |