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 line wrapping for decorated text in block output#40348

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

Merged
nicolas-grekas merged 1 commit intosymfony:4.4fromgrasmash:patch-3
Mar 17, 2021

Conversation

@grasmash
Copy link
Contributor

QA
Branch?
Bug fix?yes
New feature?no
Deprecations?no
LicenseMIT

Fixed bug that caused decorated text to be wrapped too early in SymfonyStyle->block().

@grasmash
Copy link
ContributorAuthor

Quick before and after:

- // Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et             \n- // dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea       \n- // commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla     \n- // pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim            \n- // id est laborum                                                                                                      \n+ // Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore      \n+ // magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo      \n+ // consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla             \n+ // pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id         \n+ // est laborum                                                                                                         \n

Notice that after, we are correctly filling the line with text up to 120 chars as expected. Before, the words were wrapped too early.

@carsonbot
Copy link

Hey!

I like what you have done here. Keep up the good work.

I think@Simperfit has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@stof
Copy link
Member

stof commentedMar 3, 2021

what if there is extra decoration inside the message ?

@grasmash
Copy link
ContributorAuthor

@stof

what if there is extra decoration inside the message ?

Not sure what you mean. We're measuring the "decoration" withHelper::strlen($message) - Helper::strlenWithoutDecoration($this->getFormatter(), $message);. What other decoration might there be?

@nicolas-grekasnicolas-grekas changed the titleCorrect line wrapping for decorated text in block output.[Console] Correct line wrapping for decorated text in block output.Mar 16, 2021
@grasmash
Copy link
ContributorAuthor

I'd like to note that while this PR improves the situation, it's still not perfect. The correct solution would actually be to follow the example of formatAndWrap() and actually parse the string one character at a time to wrap the line while not breaking a tag.

I looked into using formatAndWrap(), but it's problematic. We really need the wrap aspect of it and not the format aspect.

@grasmashgrasmashforce-pushed thepatch-3 branch 2 times, most recently fromff051ea toca1753bCompareMarch 16, 2021 15:02
@carsonbotcarsonbot changed the title[Console] Correct line wrapping for decorated text in block output.Correct line wrapping for decorated text in block output.Mar 17, 2021
@nicolas-grekasnicolas-grekas changed the titleCorrect line wrapping for decorated text in block output.[Console] Fix line wrapping for decorated text in block outputMar 17, 2021
@nicolas-grekas
Copy link
Member

Thank you@grasmash.

@nicolas-grekasnicolas-grekas merged commit9030fd3 intosymfony:4.4Mar 17, 2021
This was referencedMar 29, 2021
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull requestMar 30, 2021
Decorated text used to be wrapped too early in SymfonyStyle->block()Seesymfony/symfony#40348
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull requestMar 30, 2021
Decorated text used to be wrapped too early in SymfonyStyle->block()Seesymfony/symfony#40348The fix was not contributed to version 3, which means we have to rewritethe test so that it passes for both the correct and the buggy version.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

4 participants

@grasmash@carsonbot@stof@nicolas-grekas

[8]ページ先頭

©2009-2025 Movatter.jp