Skip to content
This repository
Browse code

jumping progress bar fix for windows & unix

  • Loading branch information...
commit ea74610723f789fbe478803fc71babcb5d6642f9 1 parent 6a0ee27
Robert Queck robqu authored
8 src/Symfony/Component/Console/Helper/ProgressHelper.php
@@ -36,6 +36,7 @@ class ProgressHelper extends Helper
36 36 private $format = null;
37 37 private $redrawFreq = 1;
38 38
  39 + private $lastMessagesLength;
39 40 private $barCharOriginal;
40 41
41 42 /**
@@ -384,8 +385,13 @@ private function humaneTime($secs)
384 385 private function overwrite(OutputInterface $output, $messages)
385 386 {
386 387 $output->write("\x0D"); // carriage return
387   - $output->write("\x1B\x5B\x4B"); // clear line
  388 + if($this->lastMessagesLength!==null){
  389 + $output->write(str_repeat("\x20", $this->lastMessagesLength)); //clear the line with the length of the last message
  390 + $output->write("\x0D"); // carriage return
  391 + }
388 392 $output->write($messages);
  393 +
  394 + $this->lastMessagesLength=strlen($messages);
389 395 }
390 396
391 397 /**
12 src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php
@@ -80,8 +80,18 @@ protected function getOutputStream()
80 80 return new StreamOutput(fopen('php://memory', 'r+', false));
81 81 }
82 82
  83 + protected $lastMessagesLength;
  84 +
83 85 protected function generateOutput($expected)
84 86 {
85   - return "\x0D\x1B\x5B\x4B".$expected;
  87 + $expectedout = $expected;
  88 +
  89 + if($this->lastMessagesLength!==null){
  90 + $expectedout=str_repeat("\x20", $this->lastMessagesLength)."\x0D".$expected;
  91 + }
  92 +
  93 + $this->lastMessagesLength=strlen($expected);
  94 +
  95 + return "\x0D".$expectedout;
86 96 }
87 97 }

0 comments on commit ea74610

Please sign in to comment.
Something went wrong with that request. Please try again.