Skip to content

Commit

Permalink
Fix width when title longer than column data
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrjonas committed Feb 19, 2018
1 parent 5019cff commit 8b23454
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions composer-lock-diff
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,20 @@ function tableize($header, $data, $opts = array()) {
}
}

$titles = array($header, 'From', 'To');
if (! $opts['no-links']) array_push($titles, 'Compare');

$widths = array(maxLength(array_merge(array($header), array_keys($data))));

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

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

$titles = array($header, 'From', 'To');
if (! $opts['no-links']) array_push($titles, 'Compare');

$lines[] = tabelizeLine($titles, $widths);
$lines[] = separatorLine($widths, $opts['joint']);

Expand Down

0 comments on commit 8b23454

Please sign in to comment.