Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Console] ProgressIndicator fails to clear properly when used in sections #54262

Copy link
Copy link
Open
@mfonda

Description

@mfonda
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.