Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 992aaab

Browse files
committed
fixup! Prevent ProgressBar redraw when message is same
1 parent 40210a5 commit 992aaab

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Symfony/Component/Console/Helper/ProgressBar.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ final class ProgressBar
4646
private $messages = [];
4747
private $overwrite = true;
4848
private $terminal;
49-
private $firstRun = true;
50-
private $currentMessage = '';
49+
private $previousMessage;
5150

5251
private static $formatters;
5352
private static $formats;
@@ -433,14 +432,14 @@ private function setRealFormat(string $format)
433432
*/
434433
private function overwrite(string $message): void
435434
{
436-
if ($this->currentMessage === $message) {
435+
if ($this->previousMessage === $message) {
437436
return;
438437
}
439438

440-
$this->currentMessage = $message;
439+
$originalMessage = $message;
441440

442441
if ($this->overwrite) {
443-
if (!$this->firstRun) {
442+
if (null !== $this->previousMessage) {
444443
if ($this->output instanceof ConsoleSectionOutput) {
445444
$lines = floor(Helper::strlen($message) / $this->terminal->getWidth()) + $this->formatLineCount + 1;
446445
$this->output->clear($lines);
@@ -458,7 +457,7 @@ private function overwrite(string $message): void
458457
$message = PHP_EOL.$message;
459458
}
460459

461-
$this->firstRun = false;
460+
$this->previousMessage = $originalMessage;
462461
$this->lastWriteTime = microtime(true);
463462

464463
$this->output->write($message);

0 commit comments

Comments
 (0)