Open
Description
Symfony version(s) affected
symfony/console v6.4.4
Description
Multiple ProgressIndicator
work as expected for the first handful of advance()
calls, but eventually begin to eat up all previous console output.
Run the script below to observe. Progress indicators will update as expected, but after a few iterations, all previous output already in the console window will disappear line by line.
How to reproduce
$section1 = $output->section();
$section2 = $output->section();
$progress1 = new ProgressIndicator($section1);
$progress2 = new ProgressIndicator($section2);
$progress1->start('Indicator 1');
$progress2->start('Indicator 2');
$i = 0;
while (++$i < 100) {
$progress1->advance();
$progress2->advance();
usleep(50000);
}
Possible Solution
The problem appears to be how ProgressIndicator::overwrite()
handles clearing the line.
Currently, it does the following:
$this->output->write("\x0D\x1B[2K");
This doesn't seem to be correct when used in a section. Changing it to the following fixes the bug:
use Symfony\Component\Console\Output\ConsoleSectionOutput;
...
if ($this->output instanceof ConsoleSectionOutput) {
$this->output->clear(1);
} else {
$this->output->write("\x0D\x1B[2K");
}
Additional Context
No response