@@ -377,9 +377,6 @@ function addTableLine(prefix, width) {
377
377
}
378
378
379
379
const kHorizontalEllipsis = '\u2026' ;
380
- function truncateStart ( string , width ) {
381
- return string . length > width ? `${ kHorizontalEllipsis } ${ StringPrototypeSlice ( string , string . length - width + 1 ) } ` : string ;
382
- }
383
380
384
381
function truncateEnd ( string , width ) {
385
382
return string . length > width ? `${ StringPrototypeSlice ( string , 0 , width - 1 ) } ${ kHorizontalEllipsis } ` : string ;
@@ -454,7 +451,6 @@ function getCoverageReport(pad, summary, symbol, color, table) {
454
451
}
455
452
}
456
453
457
-
458
454
function getCell ( string , width , pad , truncate , coverage ) {
459
455
if ( ! table ) return string ;
460
456
@@ -469,6 +465,46 @@ function getCoverageReport(pad, summary, symbol, color, table) {
469
465
return result ;
470
466
}
471
467
468
+ function getfilePathMultiline ( string , width , pad , coverage ) {
469
+ if ( ! table ) return string ;
470
+
471
+ const lines = [ ] ;
472
+ let currentLine = '' ;
473
+
474
+ for ( const word of StringPrototypeSplit ( string , '\\' ) ) {
475
+ if ( currentLine . length + word . length + 1 <= width ) {
476
+ // If adding the next word fits in the current line, append it
477
+ currentLine += ( currentLine . length > 0 ? '\\' : '' ) + word ;
478
+ } else {
479
+ // If adding the next word exceeds the width, start a new line
480
+ ArrayPrototypePush ( lines , currentLine ) ;
481
+ currentLine = word ;
482
+ }
483
+ }
484
+
485
+ // Add the last line if any
486
+ if ( currentLine . length > 0 ) {
487
+ ArrayPrototypePush ( lines , currentLine ) ;
488
+ }
489
+
490
+ const truncatedLines = ArrayPrototypeMap ( lines , ( line ) => StringPrototypeSlice ( line , 0 , width ) ) ;
491
+
492
+ // Delete empty lines if any
493
+ for ( let i = 0 ; i < truncatedLines . length ; ++ i ) {
494
+ if ( truncatedLines [ i ] . length === 0 ) {
495
+ truncatedLines . splice ( i , 1 ) ;
496
+ }
497
+ }
498
+
499
+ return getCell (
500
+ ArrayPrototypeJoin ( truncatedLines , '\n' ) ,
501
+ width ,
502
+ pad ,
503
+ false ,
504
+ coverage ,
505
+ ) ;
506
+ }
507
+
472
508
// Head
473
509
if ( table ) report += addTableLine ( prefix , tableWidth ) ;
474
510
report += `${ prefix } ${ getCell ( 'file' , filePadLength , StringPrototypePadEnd , truncateEnd ) } ${ kSeparator } ` +
@@ -489,7 +525,7 @@ function getCoverageReport(pad, summary, symbol, color, table) {
489
525
} ) ;
490
526
fileCoverage /= kColumnsKeys . length ;
491
527
492
- report += `${ prefix } ${ getCell ( relativePath , filePadLength , StringPrototypePadEnd , truncateStart , fileCoverage ) } ${ kSeparator } ` +
528
+ report += `${ prefix } ${ getfilePathMultiline ( relativePath , filePadLength , StringPrototypePadEnd , fileCoverage ) } ${ kSeparator } ` +
493
529
`${ ArrayPrototypeJoin ( ArrayPrototypeMap ( coverages , ( coverage , j ) => getCell ( NumberPrototypeToFixed ( coverage , 2 ) , columnPadLengths [ j ] , StringPrototypePadStart , false , coverage ) ) , kSeparator ) } ${ kSeparator } ` +
494
530
`${ getCell ( formatUncoveredLines ( getUncoveredLines ( file . lines ) , table ) , uncoveredLinesPadLength , false , truncateEnd ) } \n` ;
495
531
}
0 commit comments