Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[Console] fixed progress bar jumping for windows & unix env #6266

Merged
merged 2 commits into from

5 participants

@robqu

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

@pborreli

Good implementation but could you please check http://symfony.com/doc/current/contributing/code/standards.html

@fabpot fabpot referenced this pull request from a commit
@fabpot fabpot merged branch robqu/patch-progressbar (PR #6266)
This PR was merged into the master branch.

Commits
-------

ea74610 jumping progress bar fix for windows & unix
6a0ee27 [Console] fixed progress bar jumping

Discussion
----------

[Console] fixed progress bar jumping for windows & unix env

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

---------------------------------------------------------------------------

by pborreli at 2012-12-11T13:58:25Z

Good implementation but could you please check http://symfony.com/doc/current/contributing/code/standards.html
8bbc64d
@fabpot fabpot merged commit ea74610 into symfony:master
@stof
Collaborator

This implementation is broken IMO: it does not track the length of the last message written (which needs to be overwritten) but of the last message overwriting another message (which has no reason to be the message you are overwriting now)

@vicb vicb referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@mmucklo mmucklo referenced this pull request from a commit
@fabpot fabpot merged branch robqu/patch-progressbar (PR #6266)
This PR was merged into the master branch.

Commits
-------

ea74610 jumping progress bar fix for windows & unix
6a0ee27 [Console] fixed progress bar jumping

Discussion
----------

[Console] fixed progress bar jumping for windows & unix env

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

---------------------------------------------------------------------------

by pborreli at 2012-12-11T13:58:25Z

Good implementation but could you please check http://symfony.com/doc/current/contributing/code/standards.html
3bc4d4b
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
Commits on Dec 11, 2012
  1. @robqu
This page is out of date. Refresh to see the latest.
View
19 src/Symfony/Component/Console/Helper/ProgressHelper.php
@@ -36,6 +36,7 @@ class ProgressHelper extends Helper
private $format = null;
private $redrawFreq = 1;
+ private $lastMessagesLength;
private $barCharOriginal;
/**
@@ -380,21 +381,17 @@ 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
+ if($this->lastMessagesLength!==null){
+ $output->write(str_repeat("\x20", $this->lastMessagesLength)); //clear the line with the length of the last message
+ $output->write("\x0D"); // carriage return
+ }
$output->write($messages);
- $output->write(str_repeat(' ', $size - strlen($messages)));
-
- // clean up the end line
- $output->write(str_repeat("\x08", $size - strlen($messages)));
- if ($newline) {
- $output->writeln('');
- }
+ $this->lastMessagesLength=strlen($messages);
}
/**
View
12 src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php
@@ -80,8 +80,18 @@ protected function getOutputStream()
return new StreamOutput(fopen('php://memory', 'r+', false));
}
+ protected $lastMessagesLength;
+
protected function generateOutput($expected)
{
- return str_repeat("\x08", 80).$expected.str_repeat(' ', 80 - strlen($expected)).str_repeat("\x08", 80 - strlen($expected));
+ $expectedout = $expected;
+
+ if($this->lastMessagesLength!==null){
+ $expectedout=str_repeat("\x20", $this->lastMessagesLength)."\x0D".$expected;
+ }
+
+ $this->lastMessagesLength=strlen($expected);
+
+ return "\x0D".$expectedout;
}
}
Something went wrong with that request. Please try again.