8000 [Console] fixed progress bar jumping · symfony/symfony@6a0ee27 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a0ee27

Browse files
author
Thomas Adam
committed
[Console] fixed progress bar jumping
1 parent d8f6021 commit 6a0ee27

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

src/Symfony/Component/Console/Helper/ProgressHelper.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -380,21 +380,12 @@ private function humaneTime($secs)
380380
*
381381
* @param OutputInterface $output An Output instance
382382
* @param string|array $messages The message as an array of lines or a single string
383-
* @param Boolean $newline Whether to add a newline or not
384-
* @param integer $size The size of line
385383
*/
386-
private function overwrite(OutputInterface $output, $messages, $newline = false, $size = 80)
384+
private function overwrite(OutputInterface $output, $messages)
387385
{
388-
$output->write(str_repeat("\x08", $size));
386+
$output->write("\x0D"); // carriage return
387+
$output->write("\x1B\x5B\x4B"); // clear line
389388
$output->write($messages);
390-
$output->write(str_repeat(' ', $size - strlen($messages)));
391-
392-
// clean up the end line
393-
$output->write(str_repeat("\x08", $size - strlen($messages)));
394-
395-
if ($newline) {
396-
$output->writeln('');
397-
}
398389
}
399390

400391
/**

src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,6 @@ protected function getOutputStream()
8282

8383
protected function generateOutput($expected)
8484
{
85-
return str_repeat("\x08", 80).$expected.str_repeat(' ', 80 - strlen($expected)).str_repeat("\x08", 80 - strlen($expected));
85+
return "\x0D\x1B\x5B\x4B".$expected;
8686
}
8787
}

0 commit comments

Comments
 (0)
0