[Console] fixed progress bar jumping #5768

Merged
merged 1 commit into from Dec 11, 2012

Conversation

Projects
None yet
4 participants
Contributor

tecbot commented Oct 17, 2012

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: -

Member

Seldaek commented Oct 17, 2012

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

Contributor

pborreli commented Oct 17, 2012

@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 :

←[K

If i remove

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

it works but then it fails on Linux

Member

Seldaek commented Oct 17, 2012

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.

Contributor

tecbot commented Oct 17, 2012

@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.

Contributor

pborreli commented Oct 17, 2012

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

Owner

fabpot commented Oct 25, 2012

Any news on this issue?

@ghost

ghost commented Oct 25, 2012

a smart solution for this problem is not possible because the windows console does not support the ANSI escape sequences: http://en.wikipedia.org/wiki/ANSI_escape_code

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

Owner

fabpot commented Dec 6, 2012

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

@ghost

ghost commented Dec 11, 2012

Done.

@fabpot fabpot merged commit 6a0ee27 into symfony:master Dec 11, 2012

1 check failed

default The Travis build failed
Details
Owner

fabpot commented Dec 11, 2012

Closing in favor of #6266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment