composer local test update
This commit is contained in:
@@ -13,6 +13,8 @@ namespace Symfony\Component\Console\Formatter;
|
||||
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
|
||||
use function Symfony\Component\String\b;
|
||||
|
||||
/**
|
||||
* Formatter class for console output.
|
||||
*
|
||||
@@ -241,7 +243,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
}
|
||||
|
||||
preg_match('~(\\n)$~', $text, $matches);
|
||||
$text = $prefix.preg_replace('~([^\\n]{'.$width.'})\\ *~', "\$1\n", $text);
|
||||
$text = $prefix.$this->addLineBreaks($text, $width);
|
||||
$text = rtrim($text, "\n").($matches[1] ?? '');
|
||||
|
||||
if (!$currentLineLength && '' !== $current && !str_ends_with($current, "\n")) {
|
||||
@@ -265,4 +267,11 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
private function addLineBreaks(string $text, int $width): string
|
||||
{
|
||||
$encoding = mb_detect_encoding($text, null, true) ?: 'UTF-8';
|
||||
|
||||
return b($text)->toCodePointString($encoding)->wordwrap($width, "\n", true)->toByteString($encoding);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ class ConsoleSectionOutput extends StreamOutput
|
||||
public function setMaxHeight(int $maxHeight): void
|
||||
{
|
||||
// when changing max height, clear output of current section and redraw again with the new height
|
||||
$existingContent = $this->popStreamContentUntilCurrentSection($this->maxHeight ? min($this->maxHeight, $this->lines) : $this->lines);
|
||||
|
||||
$previousMaxHeight = $this->maxHeight;
|
||||
$this->maxHeight = $maxHeight;
|
||||
$existingContent = $this->popStreamContentUntilCurrentSection($previousMaxHeight ? min($previousMaxHeight, $this->lines) : $this->lines);
|
||||
|
||||
parent::doWrite($this->getVisibleContent(), false);
|
||||
parent::doWrite($existingContent, false);
|
||||
@@ -119,8 +119,7 @@ class ConsoleSectionOutput extends StreamOutput
|
||||
// re-add the line break (that has been removed in the above `explode()` for
|
||||
// - every line that is not the last line
|
||||
// - if $newline is required, also add it to the last line
|
||||
// - if it's not new line, but input ending with `\PHP_EOL`
|
||||
if ($i < $count || $newline || str_ends_with($input, \PHP_EOL)) {
|
||||
if ($i < $count || $newline) {
|
||||
$lineContent .= \PHP_EOL;
|
||||
}
|
||||
|
||||
@@ -168,6 +167,12 @@ class ConsoleSectionOutput extends StreamOutput
|
||||
*/
|
||||
protected function doWrite(string $message, bool $newline)
|
||||
{
|
||||
// Simulate newline behavior for consistent output formatting, avoiding extra logic
|
||||
if (!$newline && str_ends_with($message, \PHP_EOL)) {
|
||||
$message = substr($message, 0, -\strlen(\PHP_EOL));
|
||||
$newline = true;
|
||||
}
|
||||
|
||||
if (!$this->isDecorated()) {
|
||||
parent::doWrite($message, $newline);
|
||||
|
||||
@@ -213,7 +218,7 @@ class ConsoleSectionOutput extends StreamOutput
|
||||
break;
|
||||
}
|
||||
|
||||
$numberOfLinesToClear += $section->lines;
|
||||
$numberOfLinesToClear += $section->maxHeight ? min($section->lines, $section->maxHeight) : $section->lines;
|
||||
if ('' !== $sectionContent = $section->getVisibleContent()) {
|
||||
if (!str_ends_with($sectionContent, \PHP_EOL)) {
|
||||
$sectionContent .= \PHP_EOL;
|
||||
|
||||
Reference in New Issue
Block a user