@@ -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 );
0 commit comments