Skip to content

Commit 902b698

Browse files
Merge branch '6.1' into 6.2
* 6.1: [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 [FrameworkBundle] Removed unused $willBeAvailable params on Configuration [Cache] Remove extra type condition in MemcachedAdapter::createConnection() Tell about messenger:consume invalid limit options [Messenger] Do not throw 'no handlers' exception when skipping due to duplicate handling
2 parents e308591 + 90e03ec commit 902b698

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
@@ -470,10 +470,13 @@ private function overwrite(string $message): void
470470
}
471471
$this->output->clear($lineCount);
472472
} else {
473-
for ($i = 0; $i < $this->formatLineCount; ++$i) {
474-
$this->cursor->moveToColumn(1);
475-
$this->cursor->clearLine();
476-
$this->cursor->moveUp();
473+
if ('' !== $this->previousMessage) {
474+
// only clear upper lines when last call was not a clear
475+
for ($i = 0; $i < $this->formatLineCount; ++$i) {
476+
$this->cursor->moveToColumn(1);
477+
$this->cursor->clearLine();
478+
$this->cursor->moveUp();
479+
}
477480
}
478481

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

Tests/Helper/ProgressBarTest.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,8 +875,10 @@ public function testMultilineFormat()
875875
$this->assertEquals(
876876
">---------------------------\nfoobar".
877877
$this->generateOutput("=========>------------------\nfoobar").
878-
"\x1B[1G\x1B[2K\x1B[1A\x1B[1G\x1B[2K".
879-
$this->generateOutput("============================\nfoobar"),
878+
"\x1B[1G\x1B[2K\x1B[1A".
879+
$this->generateOutput('').
880+
$this->generateOutput('============================').
881+
"\nfoobar",
880882
stream_get_contents($output->getStream())
881883
);
882884
}
@@ -1187,4 +1189,29 @@ public function testMultiLineFormatIsFullyCleared()
11871189
stream_get_contents($output->getStream())
11881190
);
11891191
}
1192+
1193+
public function testMultiLineFormatIsFullyCorrectlyWithManuallyCleanup()
1194+
{
1195+
ProgressBar::setFormatDefinition('normal_nomax', "[%bar%]\n%message%");
1196+
$bar = new ProgressBar($output = $this->getOutputStream());
1197+
$bar->setMessage('Processing "foobar"...');
1198+
$bar->start();
1199+
$bar->clear();
1200+
$output->writeln('Foo!');
1201+
$bar->display();
1202+
$bar->finish();
1203+
1204+
rewind($output->getStream());
1205+
$this->assertEquals(
1206+
"[>---------------------------]\n".
1207+
'Processing "foobar"...'.
1208+
"\x1B[1G\x1B[2K\x1B[1A".
1209+
$this->generateOutput('').
1210+
'Foo!'.\PHP_EOL.
1211+
$this->generateOutput('[--->------------------------]').
1212+
"\nProcessing \"foobar\"...".
1213+
$this->generateOutput("[----->----------------------]\nProcessing \"foobar\"..."),
1214+
stream_get_contents($output->getStream())
1215+
);
1216+
}
11901217
}

0 commit comments

Comments
 (0)