Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d2b3511

Browse filesBrowse files
Fix
1 parent c34d5f6 commit d2b3511
Copy full SHA for d2b3511

File tree

1 file changed

+8
-6
lines changed
Filter options
  • src/Symfony/Component/Console/Helper

1 file changed

+8
-6
lines changed

‎src/Symfony/Component/Console/Helper/Table.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/Table.php
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,13 @@ private function buildTableRows(array $rows): TableRows
618618
if (isset($this->columnMaxWidths[$column]) && Helper::width(Helper::removeDecoration($formatter, $cell)) > $this->columnMaxWidths[$column]) {
619619
$cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column] * $colspan);
620620
}
621-
if (!strstr($cell ?? '', \PHP_EOL)) {
621+
if (!strstr($cell ?? '', "\n")) {
622622
continue;
623623
}
624-
$escaped = implode(\PHP_EOL, array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode(\PHP_EOL, $cell)));
624+
$eol = strstr($cell ?? '', "\r\n") ? "\r\n" : "\n";
625+
$escaped = implode($eol, array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode($eol, $cell)));
625626
$cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped;
626-
$lines = explode(\PHP_EOL, str_replace(\PHP_EOL, '<fg=default;bg=default></>'.\PHP_EOL, $cell));
627+
$lines = explode($eol, str_replace($eol, '<fg=default;bg=default></>'.$eol, $cell));
627628
foreach ($lines as $lineKey => $line) {
628629
if ($colspan > 1) {
629630
$line = new TableCell($line, ['colspan' => $colspan]);
@@ -684,9 +685,10 @@ private function fillNextRows(array $rows, int $line): array
684685
if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
685686
$nbLines = $cell->getRowspan() - 1;
686687
$lines = [$cell];
687-
if (strstr($cell, \PHP_EOL)) {
688-
$lines = explode(\PHP_EOL, str_replace(\PHP_EOL, '<fg=default;bg=default>'.\PHP_EOL.'</>', $cell));
689-
$nbLines = \count($lines) > $nbLines ? substr_count($cell, \PHP_EOL) : $nbLines;
688+
if (strstr($cell, "\n")) {
689+
$eol = strstr($cell, "\r\n") ? "\r\n" : "\n";
690+
$lines = explode($eol, str_replace($eol, '<fg=default;bg=default>'.$eol.'</>', $cell));
691+
$nbLines = \count($lines) > $nbLines ? substr_count($cell, $eol) : $nbLines;
690692

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.