Skip to content

Commit 65427ec

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Messenger] cs fix [Messenger] Fix time-limit check exception [Console] Fix console `ProgressBar::override()` after manual `ProgressBar::cleanup()` [FrameworkBundle] typo default_lifetime example [HttpClient] Handle Amp HTTP client v5 incompatibility gracefully [HttpKernel] Don’t try to wire Response argument with controller.service_arguments [PhpUnitBridge] Fix language deprecations incorrectly marked as direct Tell about messenger:consume invalid limit options [Messenger] Do not throw 'no handlers' exception when skipping due to duplicate handling
2 parents b0b9107 + 0c6f9ac commit 65427ec

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

Exception/InvalidOptionException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Console\Exception;
1313

1414
/**
15-
* Represents an incorrect option name typed in the console.
15+
* Represents an incorrect option name or value typed in the console.
1616
*
1717
* @author Jérôme Tamarelle <[email protected]>
1818
*/

Helper/ProgressBar.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,13 @@ private function overwrite(string $message): void
466466
}
467467
$this->output->clear($lineCount);
468468
} else {
469-
for ($i = 0; $i < $this->formatLineCount; ++$i) {
470-
$this->cursor->moveToColumn(1);
471-
$this->cursor->clearLine();
472-
$this->cursor->moveUp();
469+
if ('' !== $this->previousMessage) {
470+
// only clear upper lines when last call was not a clear
471+
for ($i = 0; $i < $this->formatLineCount; ++$i) {
472+
$this->cursor->moveToColumn(1);
473+
$this->cursor->clearLine();
474+
$this->cursor->moveUp();
475+
}
473476
}
474477

475478
$this->cursor->moveToColumn(1);

Tests/Helper/ProgressBarTest.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,10 @@ public function testMultilineFormat()
812812
$this->assertEquals(
813813
">---------------------------\nfoobar".
814814
$this->generateOutput("=========>------------------\nfoobar").
815-
"\x1B[1G\x1B[2K\x1B[1A\x1B[1G\x1B[2K".
816-
$this->generateOutput("============================\nfoobar"),
815+
"\x1B[1G\x1B[2K\x1B[1A".
816+
$this->generateOutput('').
817+
$this->generateOutput('============================').
818+
"\nfoobar",
817819
stream_get_contents($output->getStream())
818820
);
819821
}
@@ -1124,4 +1126,29 @@ public function testMultiLineFormatIsFullyCleared()
11241126
stream_get_contents($output->getStream())
11251127
);
11261128
}
1129+
1130+
public function testMultiLineFormatIsFullyCorrectlyWithManuallyCleanup()
1131+
{
1132+
ProgressBar::setFormatDefinition('normal_nomax', "[%bar%]\n%message%");
1133+
$bar = new ProgressBar($output = $this->getOutputStream());
1134+
$bar->setMessage('Processing "foobar"...');
1135+
$bar->start();
1136+
$bar->clear();
1137+
$output->writeln('Foo!');
1138+
$bar->display();
1139+
$bar->finish();
1140+
1141+
rewind($output->getStream());
1142+
$this->assertEquals(
1143+
"[>---------------------------]\n".
1144+
'Processing "foobar"...'.
1145+
"\x1B[1G\x1B[2K\x1B[1A".
1146+
$this->generateOutput('').
1147+
'Foo!'.\PHP_EOL.
1148+
$this->generateOutput('[--->------------------------]').
1149+
"\nProcessing \"foobar\"...".
1150+
$this->generateOutput("[----->----------------------]\nProcessing \"foobar\"..."),
1151+
stream_get_contents($output->getStream())
1152+
);
1153+
}
11271154
}

0 commit comments

Comments
 (0)