Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Feb 19, 2024
1 parent c34d5f6 commit d6def97
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Symfony/Component/Console/Helper/Table.php
Expand Up @@ -618,12 +618,13 @@ private function buildTableRows(array $rows): TableRows
if (isset($this->columnMaxWidths[$column]) && Helper::width(Helper::removeDecoration($formatter, $cell)) > $this->columnMaxWidths[$column]) {
$cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column] * $colspan);
}
if (!strstr($cell ?? '', \PHP_EOL)) {
if (!strstr($cell ?? '', "\n")) {
continue;
}
$escaped = implode(\PHP_EOL, array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode(\PHP_EOL, $cell)));
$eol = strstr($cell ?? '', \PHP_EOL) ? \PHP_EOL : "\n";
$escaped = implode($eol, array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode($eol, $cell)));
$cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped;
$lines = explode(\PHP_EOL, str_replace(\PHP_EOL, '<fg=default;bg=default></>'.\PHP_EOL, $cell));
$lines = explode($eol, str_replace($eol, '<fg=default;bg=default></>'.$eol, $cell));
foreach ($lines as $lineKey => $line) {
if ($colspan > 1) {
$line = new TableCell($line, ['colspan' => $colspan]);
Expand Down Expand Up @@ -684,9 +685,10 @@ private function fillNextRows(array $rows, int $line): array
if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
$nbLines = $cell->getRowspan() - 1;
$lines = [$cell];
if (strstr($cell, \PHP_EOL)) {
$lines = explode(\PHP_EOL, str_replace(\PHP_EOL, '<fg=default;bg=default>'.\PHP_EOL.'</>', $cell));
$nbLines = \count($lines) > $nbLines ? substr_count($cell, \PHP_EOL) : $nbLines;
if (strstr($cell, "\n")) {
$eol = strstr($cell, \PHP_EOL) ? \PHP_EOL : "\n";
$lines = explode($eol, str_replace($eol, '<fg=default;bg=default>'.$eol.'</>', $cell));
$nbLines = \count($lines) > $nbLines ? substr_count($cell, $eol) : $nbLines;

$rows[$line][$column] = new TableCell($lines[0], ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]);
unset($lines[0]);
Expand Down

0 comments on commit d6def97

Please sign in to comment.