@@ -342,9 +342,6 @@ function addTableLine(prefix, width) {
342
342
}
343
343
344
344
const kHorizontalEllipsis = '\u2026' ;
345
- function truncateStart ( string , width ) {
346
- return string . length > width ? `${ kHorizontalEllipsis } ${ StringPrototypeSlice ( string , string . length - width + 1 ) } ` : string ;
347
- }
348
345
349
346
function truncateEnd ( string , width ) {
350
347
return string . length > width ? `${ StringPrototypeSlice ( string , 0 , width - 1 ) } ${ kHorizontalEllipsis } ` : string ;
@@ -419,7 +416,6 @@ function getCoverageReport(pad, summary, symbol, color, table) {
419
416
}
420
417
}
421
418
422
-
423
419
function getCell ( string , width , pad , truncate , coverage ) {
424
420
if ( ! table ) return string ;
425
421
@@ -434,6 +430,46 @@ function getCoverageReport(pad, summary, symbol, color, table) {
434
430
return result ;
435
431
}
436
432
433
+ function getfilePathMultiline ( string , width , pad , coverage ) {
434
+ if ( ! table ) return string ;
435
+
436
+ const lines = [ ] ;
437
+ let currentLine = '' ;
438
+
439
+ for ( const word of StringPrototypeSplit ( string , '\\' ) ) {
440
+ if ( currentLine . length + word . length + 1 <= width ) {
441
+ // If adding the next word fits in the current line, append it
442
+ currentLine += ( currentLine . length > 0 ? '\\' : '' ) + word ;
443
+ } else {
444
+ // If adding the next word exceeds the width, start a new line
445
+ ArrayPrototypePush ( lines , currentLine ) ;
446
+ currentLine = word ;
447
+ }
448
+ }
449
+
450
+ // Add the last line if any
451
+ if ( currentLine . length > 0 ) {
452
+ ArrayPrototypePush ( lines , currentLine ) ;
453
+ }
454
+
455
+ const truncatedLines = ArrayPrototypeMap ( lines , ( line ) => StringPrototypeSlice ( line , 0 , width ) ) ;
456
+
457
+ // Delete empty lines if any
458
+ for ( let i = 0 ; i < truncatedLines . length ; ++ i ) {
459
+ if ( truncatedLines [ i ] . length === 0 ) {
460
+ truncatedLines . splice ( i , 1 ) ;
461
+ }
462
+ }
463
+
464
+ return getCell (
465
+ ArrayPrototypeJoin ( truncatedLines , '\n' ) ,
466
+ width ,
467
+ pad ,
468
+ false ,
469
+ coverage ,
470
+ ) ;
471
+ }
472
+
437
473
// Head
438
474
if ( table ) report += addTableLine ( prefix , tableWidth ) ;
439
475
report += `${ prefix } ${ getCell ( 'file' , filePadLength , StringPrototypePadEnd , truncateEnd ) } ${ kSeparator } ` +
@@ -454,7 +490,7 @@ function getCoverageReport(pad, summary, symbol, color, table) {
454
490
} ) ;
455
491
fileCoverage /= kColumnsKeys . length ;
456
492
457
- report += `${ prefix } ${ getCell ( relativePath , filePadLength , StringPrototypePadEnd , truncateStart , fileCoverage ) } ${ kSeparator } ` +
493
+ report += `${ prefix } ${ getfilePathMultiline ( relativePath , filePadLength , StringPrototypePadEnd , fileCoverage ) } ${ kSeparator } ` +
458
494
`${ ArrayPrototypeJoin ( ArrayPrototypeMap ( coverages , ( coverage , j ) => getCell ( NumberPrototypeToFixed ( coverage , 2 ) , columnPadLengths [ j ] , StringPrototypePadStart , false , coverage ) ) , kSeparator ) } ${ kSeparator } ` +
459
495
`${ getCell ( formatUncoveredLines ( getUncoveredLines ( file . lines ) , table ) , uncoveredLinesPadLength , false , truncateEnd ) } \n` ;
460
496
}
0 commit comments