@@ -471,7 +471,12 @@ private function createBlock(iterable $messages, string $type = null, string $st
471
471
$ message = OutputFormatter::escape ($ message );
472
472
}
473
473
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
+ }
475
480
476
481
if (\count ($ messages ) > 1 && $ key < \count ($ messages ) - 1 ) {
477
482
$ lines [] = '' ;
@@ -491,7 +496,9 @@ private function createBlock(iterable $messages, string $type = null, string $st
491
496
}
492
497
493
498
$ 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 ));
495
502
496
503
if ($ style ) {
497
504
$ line = sprintf ('<%s>%s</> ' , $ style , $ line );
0 commit comments