[Console] Fix line wrapping for decorated text in block output
This commit is contained in:
parent
a78fb1832b
commit
760be88310
@ -471,7 +471,12 @@ class SymfonyStyle extends OutputStyle
|
|||||||
$message = OutputFormatter::escape($message);
|
$message = OutputFormatter::escape($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
$lines = array_merge($lines, explode(\PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, \PHP_EOL, true)));
|
$decorationLength = Helper::strlen($message) - Helper::strlenWithoutDecoration($this->getFormatter(), $message);
|
||||||
|
$messageLineLength = min($this->lineLength - $prefixLength - $indentLength + $decorationLength, $this->lineLength);
|
||||||
|
$messageLines = explode(\PHP_EOL, wordwrap($message, $messageLineLength, \PHP_EOL, true));
|
||||||
|
foreach ($messageLines as $messageLine) {
|
||||||
|
$lines[] = $messageLine;
|
||||||
|
}
|
||||||
|
|
||||||
if (\count($messages) > 1 && $key < \count($messages) - 1) {
|
if (\count($messages) > 1 && $key < \count($messages) - 1) {
|
||||||
$lines[] = '';
|
$lines[] = '';
|
||||||
@ -491,7 +496,9 @@ class SymfonyStyle extends OutputStyle
|
|||||||
}
|
}
|
||||||
|
|
||||||
$line = $prefix.$line;
|
$line = $prefix.$line;
|
||||||
$line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
|
$decorationLength = Helper::strlen($line) - Helper::strlenWithoutDecoration($this->getFormatter(), $line);
|
||||||
|
$messageLineLength = min($this->lineLength - $prefixLength - $indentLength + $decorationLength, $this->lineLength);
|
||||||
|
$line .= str_repeat(' ', max($this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line), 0));
|
||||||
|
|
||||||
if ($style) {
|
if ($style) {
|
||||||
$line = sprintf('<%s>%s</>', $style, $line);
|
$line = sprintf('<%s>%s</>', $style, $line);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
[39;49m // [39;49mLorem ipsum dolor sit [33mamet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et [39m
|
[39;49m // [39;49mLorem ipsum dolor sit [33mamet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore [39m
|
||||||
[39;49m // [39;49m[33mdolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea [39m
|
[39;49m // [39;49m[33mmagna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo [39m
|
||||||
[39;49m // [39;49m[33mcommodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla [39m
|
[39;49m // [39;49m[33mconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla [39m
|
||||||
[39;49m // [39;49m[33mpariatur.[39m Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim
|
[39;49m // [39;49m[33mpariatur.[39m Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
|
||||||
[39;49m // [39;49mid est laborum
|
[39;49m // [39;49mest laborum
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user