Skip to content

Commit 8b23454

Browse files
committed
Fix width when title longer than column data
1 parent 5019cff commit 8b23454

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

composer-lock-diff

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,20 @@ function tableize($header, $data, $opts = array()) {
8585
}
8686
}
8787

88+
$titles = array($header, 'From', 'To');
89+
if (! $opts['no-links']) array_push($titles, 'Compare');
90+
8891
$widths = array(maxLength(array_merge(array($header), array_keys($data))));
8992

9093
$count = count(reset($data));
9194
for($i = 0; $i < $count; $i++) {
92-
$widths[] = maxLength(array_map(function($k) use ($data, $i) { return $data[$k][$i]; }, array_keys($data)));
95+
$widths[] = max(strlen($titles[$i + 1]), maxLength(array_map(function($k) use ($data, $i) { return $data[$k][$i]; }, array_keys($data))));
9396
}
9497

9598
if ($opts['capped']) {
9699
$lines[] = separatorLine($widths, $opts['joint']);
97100
}
98101

99-
$titles = array($header, 'From', 'To');
100-
if (! $opts['no-links']) array_push($titles, 'Compare');
101-
102102
$lines[] = tabelizeLine($titles, $widths);
103103
$lines[] = separatorLine($widths, $opts['joint']);
104104

0 commit comments

Comments
 (0)