@@ -357,8 +357,10 @@ export function convertRowsToConsole(rows: string[]): string[] {
357357 }
358358
359359 const columnCounters = vector [ 0 ] . reduce ( ( counters : number [ ] , _ , j ) => {
360+ // get max width of column, splitting values by new line
360361 const maxLength = vector . reduce (
361- ( max , row ) => Math . max ( max , row [ j ] . length ) ,
362+ ( max , row ) =>
363+ Math . max ( max , Math . max ( ...row [ j ] . split ( "\n" ) . map ( ( l ) => l . length ) ) ) ,
362364 0 ,
363365 ) ;
364366 counters . push ( maxLength + 2 ) ;
@@ -368,14 +370,27 @@ export function convertRowsToConsole(rows: string[]): string[] {
368370 vector . forEach ( ( row ) => {
369371 row . forEach ( ( value , j ) => {
370372 const counter = columnCounters [ j ] ;
371- const diff = counter - value . length ;
372- if ( diff > 0 ) {
373- if ( ! haveHeader && j !== columnCounters . length - 1 ) {
374- row [ j ] = value + "|" + " " . repeat ( diff > 1 ? diff - 1 : diff ) ;
375- } else {
376- row [ j ] = value + " " . repeat ( diff ) ;
373+ const lines = value . split ( "\n" ) ;
374+ row [ j ] = "" ;
375+
376+ lines . forEach ( ( line , lineIndex ) => {
377+ if ( lineIndex > 0 ) {
378+ // prepend spacing to align lines within the same cell
379+ const prevCol = columnCounters [ j - 1 ] ;
380+ if ( prevCol ) {
381+ row [ j ] += "\n" + " " . repeat ( prevCol ) ;
382+ }
377383 }
378- }
384+
385+ const diff = counter - line . length ;
386+ if ( diff > 0 ) {
387+ if ( ! haveHeader && j !== columnCounters . length - 1 ) {
388+ row [ j ] += line + "|" + " " . repeat ( diff > 1 ? diff - 1 : diff ) ;
389+ } else {
390+ row [ j ] += line + " " . repeat ( diff ) ;
391+ }
392+ }
393+ } ) ;
379394 } ) ;
380395 } ) ;
381396
0 commit comments