cli-table2 icon indicating copy to clipboard operation
cli-table2 copied to clipboard

Colors in word-wrapped table bleed when closing ANSI sequence wrapped in newlines

Open jfr3000 opened this issue 7 years ago • 0 comments

This is an edge case, but it managed to trip me up. Failing test:

 it('wordWrap with colored text should not bleed',function(){
    var table = new Table({style:{border:[],head:[]},wordWrap:true,colWidths:[8]});

    table.push([colors.blue('Hello how are you?\n') + '\nthis should be white']);

    var expected = [ 
        '┌────────┐'
      , '│ ' + colors.blue('Hello') + '  │'
      , '│ ' + colors.blue('how') + '    │'
      , '│ ' + colors.blue('are') + '    │'
      , '│ ' + colors.blue('you?') + '   │'
      , '│ ' + 'this' + '   │'
      , '│ ' + 'should' + ' │'
      , '│ ' + 'be' + '     │'
      , '│ ' + 'white' + '  │'
      , '└────────┘'
    ];  

    expect(table.toString()).to.equal(expected.join('\n'));
  }); 

jfr3000 avatar May 09 '17 11:05 jfr3000