Skip to content

Commit

Permalink
bug #44915 [Console] Fix compact table style to avoid outputting a le…
Browse files Browse the repository at this point in the history
…ading space (Seldaek)

This PR was merged into the 4.4 branch.

Discussion
----------

[Console] Fix compact table style to avoid outputting a leading space

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

This changes the `compact` output from:

```
 a   b   \n
 foo bar \n
```

To:

```
a   b   \n
foo bar \n
```

Note the only difference is the leading space which is not there anymore.

IMO this is a much better default, but I do understand it changes something which has been as it is for ages, which may be considered a BC break more than a bugfix.

Commits
-------

5ffedf5 [Console] Fix compact table style to avoid outputting a leading space
  • Loading branch information
chalasr committed Mar 16, 2022
2 parents f1f123b + 5ffedf5 commit c1aa7b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Helper/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,9 @@ private static function initStyles(): array
$compact = new TableStyle();
$compact
->setHorizontalBorderChars('')
->setVerticalBorderChars(' ')
->setVerticalBorderChars('')
->setDefaultCrossingChar('')
->setCellRowContentFormat('%s')
->setCellRowContentFormat('%s ')
;

$styleGuide = new TableStyle();
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Component/Console/Tests/Helper/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ public function renderProvider()
$books,
'compact',
<<<'TABLE'
ISBN Title Author
99921-58-10-7 Divine Comedy Dante Alighieri
9971-5-0210-0 A Tale of Two Cities Charles Dickens
960-425-059-0 The Lord of the Rings J. R. R. Tolkien
80-902734-1-6 And Then There Were None Agatha Christie
ISBN Title Author
99921-58-10-7 Divine Comedy Dante Alighieri
9971-5-0210-0 A Tale of Two Cities Charles Dickens
960-425-059-0 The Lord of the Rings J. R. R. Tolkien
80-902734-1-6 And Then There Were None Agatha Christie
TABLE
],
Expand Down

0 comments on commit c1aa7b5

Please sign in to comment.