Skip to content

Commit 3e4cda0

Browse files
committed
[Console][Table] fixed render when using multiple rowspans.
1 parent 2c302ce commit 3e4cda0

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ private function fillNextRows($rows, $line)
394394
foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
395395
$value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
396396
$unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan()));
397+
if ($nbLines === $unmergedRowKey) {
398+
break;
399+
}
397400
}
398401
}
399402
}

src/Symfony/Component/Console/Tests/Helper/TableTest.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -298,29 +298,29 @@ public function testRenderProvider()
298298
array(
299299
array(
300300
new TableCell('9971-5-0210-0', array('rowspan' => 3)),
301-
'Divine Comedy',
301+
new TableCell('Divine Comedy', array('rowspan' => 2)),
302302
'Dante Alighieri',
303303
),
304-
array('A Tale of Two Cities', 'Charles Dickens'),
304+
array(),
305305
array("The Lord of \nthe Rings", "J. R. \nR. Tolkien"),
306306
new TableSeparator(),
307307
array('80-902734-1-6', new TableCell("And Then \nThere \nWere None", array('rowspan' => 3)), 'Agatha Christie'),
308308
array('80-902734-1-7', 'Test'),
309309
),
310310
'default',
311311
<<<'TABLE'
312-
+---------------+----------------------+-----------------+
313-
| ISBN | Title | Author |
314-
+---------------+----------------------+-----------------+
315-
| 9971-5-0210-0 | Divine Comedy | Dante Alighieri |
316-
| | A Tale of Two Cities | Charles Dickens |
317-
| | The Lord of | J. R. |
318-
| | the Rings | R. Tolkien |
319-
+---------------+----------------------+-----------------+
320-
| 80-902734-1-6 | And Then | Agatha Christie |
321-
| 80-902734-1-7 | There | Test |
322-
| | Were None | |
323-
+---------------+----------------------+-----------------+
312+
+---------------+---------------+-----------------+
313+
| ISBN | Title | Author |
314+
+---------------+---------------+-----------------+
315+
| 9971-5-0210-0 | Divine Comedy | Dante Alighieri |
316+
| | | |
317+
| | The Lord of | J. R. |
318+
| | the Rings | R. Tolkien |
319+
+---------------+---------------+-----------------+
320+
| 80-902734-1-6 | And Then | Agatha Christie |
321+
| 80-902734-1-7 | There | Test |
322+
| | Were None | |
323+
+---------------+---------------+-----------------+
324324

325325
TABLE
326326
),

0 commit comments

Comments
 (0)