File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -17,9 +17,7 @@ export function breakLines(content: string, width: number): string {
1717 let escapeSequence = '' ;
1818 let inEscape = false ;
1919
20- for ( let i = 0 ; i < line . length ; i ++ ) {
21- const char = line [ i ] ! ;
22-
20+ for ( const char of line ) {
2321 // Detect start of ANSI escape code
2422 if ( char === '\x1b' ) {
2523 inEscape = true ;
@@ -31,6 +29,8 @@ export function breakLines(content: string, width: number): string {
3129 if ( inEscape ) {
3230 escapeSequence += char ;
3331
32+ // ANSI escape sequences always end with a letter (eg., 'm' in '\x1b[31m')
33+ // This marks the end of the sequence so we can append it without counting its width
3434 if ( / [ a - z A - Z ] / . test ( char ) ) {
3535 inEscape = false ;
3636 currentLine += escapeSequence ;
You can’t perform that action at this time.
0 commit comments