Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


[Console] fixed progress bar jumping #5768

merged 1 commit into from

5 participants


The progress bar is jumping around on my screen :). This patch will fix this and simplify the previous solution to clear a line.

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
License of the code: MIT
Documentation PR: -


Should be verified on various platforms I think, because the old code works well for most (we use a similar thing in composer).


@Seldaek i have same issue on Linux when launching the console from anywhere not on top of the screen.

@tecbot on Windows i have a strange character displayed at the begining of the line :


If i remove

$output->write("\x1B\x5B\x4B"); // clear line

it works but then it fails on Linux


I think the problem is that the display() method doesn't pass the barWidth and stuff to overwrite(), so it can't do its job properly. In composer what we did is always store the last message length so when you call overwrite it just uses that length to rollback to the beginning of the line, but that's maybe not feasible in the helper.


@Seldaek the composer progress on the console jumps also around on my machine (from left to right, from right to the middle and so on :D). (Debian Squeeze)

Hm maybe we can use a another solution if the env is windows? This solution works perfect on linux.


the goal of my comment was : let's try to find a way that works on all systems :)


Any news on this issue?


a smart solution for this problem is not possible because the windows console does not support the ANSI escape sequences:

my suggestion is:

$output->write("\x0D"); // carriage return
$output->write(str_repeat(' ', strlen($lastMessages))); //clear the line with the length of the last message
$output->write("\x0D"); // carriage return

this works in windows and unix but you need the last written message


@robqu Can you work on a PR that implements your suggestion?



@fabpot fabpot merged commit 6a0ee27 into from

Closing in favor of #6266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 17, 2012
  1. @tecbot
This page is out of date. Refresh to see the latest.
15 src/Symfony/Component/Console/Helper/ProgressHelper.php
@@ -380,21 +380,12 @@ private function humaneTime($secs)
* @param OutputInterface $output An Output instance
* @param string|array $messages The message as an array of lines or a single string
- * @param Boolean $newline Whether to add a newline or not
- * @param integer $size The size of line
- private function overwrite(OutputInterface $output, $messages, $newline = false, $size = 80)
+ private function overwrite(OutputInterface $output, $messages)
- $output->write(str_repeat("\x08", $size));
+ $output->write("\x0D"); // carriage return
+ $output->write("\x1B\x5B\x4B"); // clear line
- $output->write(str_repeat(' ', $size - strlen($messages)));
- // clean up the end line
- $output->write(str_repeat("\x08", $size - strlen($messages)));
- if ($newline) {
- $output->writeln('');
- }
2  src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php
@@ -82,6 +82,6 @@ protected function getOutputStream()
protected function generateOutput($expected)
- return str_repeat("\x08", 80).$expected.str_repeat(' ', 80 - strlen($expected)).str_repeat("\x08", 80 - strlen($expected));
+ return "\x0D\x1B\x5B\x4B".$expected;
Something went wrong with that request. Please try again.