Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Console] Fix linewraps inOutputFormatter#51223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

maxbeckers
Copy link
Contributor

@maxbeckersmaxbeckers commentedAug 2, 2023
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#42034
LicenseMIT
Doc PRn/a

Fix output for tables with linebreaks and special chars;

$table =new \Symfony\Component\Console\Helper\Table($output);$table    ->setColumnMaxWidth(1,10)    ->setHeaders(['ISBN','Title'])    ->setRows([        ['99921-58-10-7','A really long title that could need multiple lines'],new \Symfony\Component\Console\Helper\TableSeparator(),        ['99921-58-10-7','Â rèälly löng tîtlè thät cöüld nèêd múltîplê línès']    ]);$table->render();

Before

+---------------+------------+| ISBN          | Title      |+---------------+------------+| 99921-58-10-7 | A really l ||               | ong title  ||               | that could ||               | need multi ||               | ple lines  |+---------------+------------+| 99921-58-10-7 | Â rèäll    ||               | y löng t ||               | tlè thä ||               | t cöüld    ||               | nèêd mú    ||               | ltîplê l   ||               | ínès       |+---------------+------------+

After

+---------------+------------+| ISBN          | Title      |+---------------+------------+| 99921-58-10-7 | A really   ||               | long title ||               | that could ||               | need       ||               | multiple   ||               | lines      |+---------------+------------+| 99921-58-10-7 | Â rèälly   ||               | löng tîtlè ||               | thät cöüld ||               | nèêd       ||               | múltîplê   ||               | línès      |+---------------+------------+

@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "6.4" but it seems your PR description refers to branch "5.4,".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@carsonbotcarsonbot added this to the6.4 milestoneAug 2, 2023
@maxbeckersmaxbeckers changed the base branch from6.4 to5.4August 2, 2023 09:05
@maxbeckersmaxbeckersforce-pushed thepatch-42034_special_chars_in_console_table branch 2 times, most recently fromec4b7af todd95114CompareAugust 2, 2023 09:09
@derrabusderrabus modified the milestones:6.4,5.4Aug 2, 2023
@maxbeckersmaxbeckersforce-pushed thepatch-42034_special_chars_in_console_table branch fromdd95114 toc52f972CompareAugust 2, 2023 09:34
@maxbeckersmaxbeckersforce-pushed thepatch-42034_special_chars_in_console_table branch 3 times, most recently frome4d46f7 to31dc48dCompareAugust 3, 2023 13:12
80-902734-1-6 And Then There Were None Agatha Christie

TABLE
implode("\n", [
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This change is only because of the line "trim_trailing_whitespace = true" in .editorconfig.

=============== ========================== ==================

TABLE
implode("\n", [
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This change is only because of the line "trim_trailing_whitespace = true" in .editorconfig.

@maxbeckersmaxbeckersforce-pushed thepatch-42034_special_chars_in_console_table branch from31dc48d to4d44010CompareAugust 7, 2023 05:59
@maxbeckersmaxbeckersforce-pushed thepatch-42034_special_chars_in_console_table branch from4d44010 tofcf86b3CompareAugust 7, 2023 06:12
$this->assertSame("pre \nfoo\nbar\nbaz \npost", $formatter->formatAndWrap('pre <error>foo bar baz</error> post', 4));
$this->assertSame("pre f\noo\nbar\nbaz p\nost", $formatter->formatAndWrap('pre <error>foo bar baz</error> post', 5));
$this->assertSame("Â rèälly\nlöng tîtlè\nthät cöüld\nnèêd\nmúltîplê\nlínès", $formatter->formatAndWrap('Â rèälly löng tîtlè thät cöüld nèêd múltîplê línès', 10));
$this->assertSame("Â rèälly\nlöng tîtlè\nthät cöüld\nnèêd\nmúltîplê\n línès", $formatter->formatAndWrap("Â rèälly löng tîtlè thät cöüld nèêd múltîplê\n línès", 10));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Are all these changes on purpose and behave as expected?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes,@nicolas-grekas (seecomment) had the idea to use wordwrap from the string component for that. Wordwrap works a bit different with the line breaks than the regex before. now it breaks the line not in a word (or only if a word is longer than the full allowed length).
Example:
"Too long li\nne" => "Too long\nline"
IMHO this makes the output more readable.

@nicolas-grekas
Copy link
Member

Thank you@maxbeckers.

@nicolas-grekasnicolas-grekas merged commit370d5c0 intosymfony:5.4Aug 14, 2023
This was referencedAug 26, 2023
renovatebot added a commit to Lendable/composer-license-checker that referenced this pull requestAug 26, 2023
[![MendRenovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)This PR contains the following updates:| Package | Type | Update | Change ||---|---|---|---|| [symfony/console](https://symfony.com)([source](https://togithub.com/symfony/console)) | require | patch |`6.3.2` -> `6.3.4` || [symfony/process](https://symfony.com)([source](https://togithub.com/symfony/process)) | require | patch |`6.3.2` -> `6.3.4` |---### Release Notes<details><summary>symfony/console (symfony/console)</summary>### [`v6.3.4`](https://togithub.com/symfony/console/releases/tag/v6.3.4)[CompareSource](https://togithub.com/symfony/console/compare/v6.3.2...v6.3.4)**Changelog**(symfony/console@v6.3.3...v6.3.4)- bug[symfony/symfony#51378](https://togithub.com/symfony/symfony/issues/51378)\[Console] avoid multiple new line when message already ends with a newline in section output([@&#8203;joelwurtz](https://togithub.com/joelwurtz))- bug[symfony/symfony#51223](https://togithub.com/symfony/symfony/issues/51223)\[Console] Fix linewraps in `OutputFormatter` (@&#8203;maxbeckers)- bug[symfony/symfony#51355](https://togithub.com/symfony/symfony/issues/51355)\[Console] fix section output when multiples section with max height([@&#8203;joelwurtz](https://togithub.com/joelwurtz))</details><details><summary>symfony/process (symfony/process)</summary>###[`v6.3.4`](https://togithub.com/symfony/process/compare/v6.3.2...v6.3.4)[CompareSource](https://togithub.com/symfony/process/compare/v6.3.2...v6.3.4)</details>---### Configuration📅 **Schedule**: Branch creation - At any time (no schedule defined),Automerge - At any time (no schedule defined).🚦 **Automerge**: Enabled.♻ **Rebasing**: Whenever PR becomes conflicted, or you tick therebase/retry checkbox.🔕 **Ignore**: Close this PR and you won't be reminded about theseupdates again.---- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, checkthis box---This PR has been generated by [MendRenovate](https://www.mend.io/free-developer-tools/renovate/). Viewrepository job log[here](https://developer.mend.io/github/Lendable/composer-license-checker).<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi41Ni4wIiwidXBkYXRlZEluVmVyIjoiMzYuNTYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@OskarStarkOskarStarkOskarStark left review comments

@derrabusderrabusderrabus left review comments

@chalasrchalasrchalasr left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
5.4
Development

Successfully merging this pull request may close these issues.

Umlauts are incorrectly separated by the OutputFormatter when creating a table for the console
6 participants
@maxbeckers@carsonbot@nicolas-grekas@OskarStark@derrabus@chalasr

[8]ページ先頭

©2009-2025 Movatter.jp