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

Appearance settings

Commit 760be88

Browse filesBrowse files
grasmashnicolas-grekas
authored andcommitted
[Console] Fix line wrapping for decorated text in block output
1 parent a78fb18 commit 760be88
Copy full SHA for 760be88

File tree

Expand file treeCollapse file tree

2 files changed

+14
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-7
lines changed

‎src/Symfony/Component/Console/Style/SymfonyStyle.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Style/SymfonyStyle.php
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,12 @@ private function createBlock(iterable $messages, string $type = null, string $st
471471
$message = OutputFormatter::escape($message);
472472
}
473473

474-
$lines = array_merge($lines, explode(\PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, \PHP_EOL, true)));
474+
$decorationLength = Helper::strlen($message) - Helper::strlenWithoutDecoration($this->getFormatter(), $message);
475+
$messageLineLength = min($this->lineLength - $prefixLength - $indentLength + $decorationLength, $this->lineLength);
476+
$messageLines = explode(\PHP_EOL, wordwrap($message, $messageLineLength, \PHP_EOL, true));
477+
foreach ($messageLines as $messageLine) {
478+
$lines[] = $messageLine;
479+
}
475480

476481
if (\count($messages) > 1 && $key < \count($messages) - 1) {
477482
$lines[] = '';
@@ -491,7 +496,9 @@ private function createBlock(iterable $messages, string $type = null, string $st
491496
}
492497

493498
$line = $prefix.$line;
494-
$line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
499+
$decorationLength = Helper::strlen($line) - Helper::strlenWithoutDecoration($this->getFormatter(), $line);
500+
$messageLineLength = min($this->lineLength - $prefixLength - $indentLength + $decorationLength, $this->lineLength);
501+
$line .= str_repeat(' ', max($this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line), 0));
495502

496503
if ($style) {
497504
$line = sprintf('<%s>%s</>', $style, $line);
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.