Skip to content

[Console] Fix console ProgressBar::override() after manual ProgressBar::cleanup() #47998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2022

Conversation

maxbeckers
Copy link
Contributor

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #47987
License MIT
Doc PR

In the issue #47987 is described, that there is a problem with overriding lines with ProgressBar::override() on a multiline console output with manual call of ProgressBar::cleanup().

Testcode:

ProgressBar::setFormatDefinition('normal_nomax', "[%bar%]\n%message%");
$progressBar = new ProgressBar($output);
$progressBar->setMessage('Processing "foobar"...');
$progressBar->start();
$progressBar->clear();
$output->writeln('Foo!');
$progressBar->display();
$progressBar->finish();

Output before the fix:

Progress bar having only one line:
Foo!
[----->----------------------]
=-=-=-=
Progress bar having two lines:
[----->----------------------]
Processing "foobar"...

Expected output / output after the fix:

Progress bar having only one line:
Foo!
[----->----------------------]
=-=-=-=
Progress bar having two lines:
Foo!
[----->----------------------]
Processing "foobar"...

@maxbeckers maxbeckers requested a review from chalasr as a code owner October 26, 2022 07:23
@carsonbot carsonbot added this to the 6.2 milestone Oct 26, 2022
@maxbeckers maxbeckers changed the base branch from 6.2 to 5.4 October 26, 2022 07:28
@maxbeckers
Copy link
Contributor Author

maxbeckers commented Oct 26, 2022

Build failures are unrelated to the change.

Should be added to Milestone 5.4, had the wrong target branch when i created the PR.

@carsonbot
Copy link

Hey!

I think @CesarScur has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@maxbeckers
Copy link
Contributor Author

To reproduce i added a zip with the fix in vendor:
test-47998.zip
Just run php testcommand.php in root.

Output without the fix:

Progress bar having only one line:
Foo!
[----->----------------------]
=-=-=-=
Progress bar having two lines:
[----->----------------------]
Processing "foobar"...
============================
foobar

Output with the fix:


Progress bar having only one line:
Foo!
[----->----------------------]
=-=-=-=
Progress bar having two lines:
Foo!
[----->----------------------]
Processing "foobar"...
=-=-=-=
============================
foobar

@nicolas-grekas nicolas-grekas modified the milestones: 6.2, 5.4 Nov 9, 2022
@fabpot
Copy link
Member

fabpot commented Nov 11, 2022

Thank you @maxbeckers.

@fabpot fabpot merged commit 1d2e025 into symfony:5.4 Nov 11, 2022
@fabpot fabpot mentioned this pull request Nov 19, 2022
This was referenced Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Console] Progress bar clear/display remove too many lines
4 participants