Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

jumping progress bar fix for windows & unix

  • Loading branch information...
commit ea74610723f789fbe478803fc71babcb5d6642f9 1 parent 6a0ee27
@robqu robqu authored
View
8 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;
/**
@@ -384,8 +385,13 @@ private function humaneTime($secs)
private function overwrite(OutputInterface $output, $messages)
{
$output->write("\x0D"); // carriage return
- $output->write("\x1B\x5B\x4B"); // clear line
+ 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);
+
+ $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 "\x0D\x1B\x5B\x4B".$expected;
+ $expectedout = $expected;
+
+ if($this->lastMessagesLength!==null){
+ $expectedout=str_repeat("\x20", $this->lastMessagesLength)."\x0D".$expected;
+ }
+
+ $this->lastMessagesLength=strlen($expected);
+
+ return "\x0D".$expectedout;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.