You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a reason why the console component's OutputFormatter class might not be counting my newlines (\n) in the $width calculation? I am getting funny line wrapping behavior when I try to output multi-line text to the console.
Example 1 - text from a yaml file (wrapping at $width = 80):
motd: "\n
\n<c>===== MESSAGE OF THE DAY =====</>
\n
\nThis is the first sentence of the multi-line text, which will end here.
\nWe are now on the second sentence of the text, which should end here."
And the console output, after using OutputFormatter->formatAndWrap() is:
===== MESSAGE OF THE DAY =====
This is the first sentence of the multi-line
text, which will end here.
We are now on the second sentence of the text, which should end here.
It looks like it's wrapping the third line ("This is the first...") based on the character length from the first two lines as well.
Example 2 - text from a twig file (wrapping at $width = 80):
// motd.twig
<c>===== MESSAGE OF THE DAY =====</>
This is the first sentence of the multi-line text, which will end here.
We are now on the second sentence of the text, which should end here.
Console output:
===== MESSAGE OF THE DAY =====
This is the first sentence of the multi-line tex
t, which will end here.
We are now on the second sentence of the text, which should end here.
I'm at a loss, but it looks like OutputFormatter is not properly factoring in some of the new lines and resetting the width at the beginning of the lines.
EDIT: With a bit more testing, it looks like the improper wrapping only happens when styles are being applied. If I remove the and </> tags, the line wrapping works just fine.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
{{title}}
{{editor}}'s edit
{{editor}}'s edit
-
Is there a reason why the console component's OutputFormatter class might not be counting my newlines (\n) in the $width calculation? I am getting funny line wrapping behavior when I try to output multi-line text to the console.
Example 1 - text from a yaml file (wrapping at $width = 80):
And the console output, after using OutputFormatter->formatAndWrap() is:
It looks like it's wrapping the third line ("This is the first...") based on the character length from the first two lines as well.
Example 2 - text from a twig file (wrapping at $width = 80):
Console output:
I'm at a loss, but it looks like OutputFormatter is not properly factoring in some of the new lines and resetting the width at the beginning of the lines.
EDIT: With a bit more testing, it looks like the improper wrapping only happens when styles are being applied. If I remove the and </> tags, the line wrapping works just fine.
Beta Was this translation helpful? Give feedback.
All reactions