Subject: | allowANSI breaks table alignment if two identical column names are used |
This example code:
use 5.014;
use strict;
use warnings;
my @data = (
[0, 'xxxxxxx xxxxxxx' , 'xxxxxxx'],
[0, 'xxxxxxxxxxx xxxxxxx' , 'xxxxxxx'],
[0, 'xxxxxxxx-xxxxxxx' , 'xxxxxxxx'],
[0, 'xxxxxxxx-xxxxxxx' , 'xxxxxxxx'],
[0, 'xxxx-xxxxxxxx xxxxxxx' , 'xxxx-xxxxxxxx'],
[0, 'xxxxxxxxx-xxxxxxx' , 'xxxxxxxxx-xxxxxxx'],
[1, 'xxxxxxxxxxxxxx xxxxxx' , 'xxxxxxx'],
[1, 'xxxxxx xxxxxxxxxx' , 'xxxxxxx'],
);
use Text::ASCIITable;
my $t = Text::ASCIITable->new();
$t->setCols('rank', 'name', 'name');
$t->setOptions(allowANSI => 1);
$t->addRow(@$_) for @data;
print $t;
produces:
.----------------------------------------------.
| rank | name | name |
+------+-------------------+-------------------+
| 0 | xxxxxxx xxxxxxx | xxxxxxx |
| 0 | xxxxxxxxxxx xxxxxxx | xxxxxxx |
| 0 | xxxxxxxx-xxxxxxx | xxxxxxxx |
| 0 | xxxxxxxx-xxxxxxx | xxxxxxxx |
| 0 | xxxx-xxxxxxxx xxxxxxx | xxxx-xxxxxxxx |
| 0 | xxxxxxxxx-xxxxxxx | xxxxxxxxx-xxxxxxx |
| 1 | xxxxxxxxxxxxxx xxxxxx | xxxxxxx |
| 1 | xxxxxx xxxxxxxxxx | xxxxxxx |
'------+-------------------+-------------------'
It works fine if either the column names are distinct, or allowANSI isn't set.