jumping progress bar fix for windows & unix
This commit is contained in:
parent
6a0ee27de1
commit
ea74610723
@ -36,6 +36,7 @@ class ProgressHelper extends Helper
|
||||
private $format = null;
|
||||
private $redrawFreq = 1;
|
||||
|
||||
private $lastMessagesLength;
|
||||
private $barCharOriginal;
|
||||
|
||||
/**
|
||||
@ -384,8 +385,13 @@ class ProgressHelper extends Helper
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,8 +80,18 @@ class ProgressHelperTest extends \PHPUnit_Framework_TestCase
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user