Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4:
  [DependencyInjection] Fix computing error messages involving service locators
  [Serializer] Fix unknown types normalization type when know type
  [ErrorHandler] Fix parsing messages that contain anonymous classes on PHP >= 8.3.3
  [AssetMapper] Fix enquoted string pattern
  [Validator] Review Romanian (ro) translations
  [Console] Fix display of Table on Windows OS
  [FrameworkBundle] Fix config builder with extensions extended in `build()`
  [Translation] Fix extracting qualified t() function calls
  Fix vertical table on windows
  Fix the `command -v` exception when the command option with a dash prefix
  [WebProfilerBundle] disable turbo in web profiler toolbar to avoid link prefetching
  explicitly cast boolean SSL stream options
  return the unchanged text if preg_replace_callback() fails
  the 'use_notify' option is on the factory, not on the postgres connection class
  review translations
  • Loading branch information
nicolas-grekas committed Feb 22, 2024
2 parents b95e86a + 0d9e4eb commit 6b099f3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Helper/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ public function render(): void
for ($i = 0; $i < $maxRows; ++$i) {
$cell = (string) ($row[$i] ?? '');

$parts = explode("\n", $cell);
$eol = str_contains($cell, "\r\n") ? "\r\n" : "\n";
$parts = explode($eol, $cell);
foreach ($parts as $idx => $part) {
if ($headers && !$containsColspan) {
if (0 === $idx) {
Expand Down Expand Up @@ -632,9 +633,10 @@ private function buildTableRows(array $rows): TableRows
if (!str_contains($cell ?? '', "\n")) {
continue;
}
$escaped = implode("\n", array_map(OutputFormatter::escapeTrailingBackslash(...), explode("\n", $cell)));
$eol = str_contains($cell ?? '', "\r\n") ? "\r\n" : "\n";
$escaped = implode($eol, array_map(OutputFormatter::escapeTrailingBackslash(...), explode($eol, $cell)));
$cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped;
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default></>\n", $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 @@ -696,8 +698,9 @@ private function fillNextRows(array $rows, int $line): array
$nbLines = $cell->getRowspan() - 1;
$lines = [$cell];
if (str_contains($cell, "\n")) {
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
$nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
$eol = str_contains($cell, "\r\n") ? "\r\n" : "\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 6b099f3

Please sign in to comment.