8000 Merge branch '6.4' into 7.0 · symfony/console@fde915c · GitHub
[go: up one dir, main page]

Skip to content

Commit fde915c

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: respect multi-byte characters when rendering vertical-style tables
2 parents 84d8448 + a2708a5 commit fde915c

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

Helper/Table.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,9 @@ public function render(): void
367367
if ($headers && !$containsColspan) {
368368
if (0 === $idx) {
369369
$rows[] = [sprintf(
370-
'<comment>%s</>: %s',
371-
str_pad($headers[$i] ?? '', $maxHeaderLength, ' ', \STR_PAD_LEFT),
370+
'<comment>%s%s</>: %s',
371+
str_repeat(' ', $maxHeaderLength - Helper::width(Helper::removeDecoration($formatter, $headers[$i] ?? ''))),
372+
$headers[$i] ?? '',
372373
$part
373374
)];
374375
} else {

Tests/Helper/TableTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,28 @@ public static function provideRenderVerticalTests(): \Traversable
16491649
$books,
16501650
];
16511651

1652+
yield 'With multibyte characters in some headers (the "í" in "Títle") and cells (the "í" in "Dívíne")' => [
1653+
<<<EOTXT
1654+
+-------------------------+
1655+
| ISBN: 99921-58-10-7 |
1656+
| Títle: Dívíne Comedy |
1657+
| Author: Dante Alighieri |
1658+
| Price: 9.95 |
1659+
+-------------------------+
1660+
1661+
EOTXT
1662+
,
1663+
['ISBN', 'Títle', 'Author', 'Price'],
1664+
[
1665+
[
1666+
'99921-58-10-7',
1667+
'Dívíne Comedy',
1668+
'Dante Alighieri',
1669+
'9.95',
1670+
],
1671+
],
1672+
];
1673+
16521674
yield 'With header for some' => [
16531675
<<<EOTXT
16541676
+------------------------------+

0 commit comments

Comments
 (0)
0