1
0
Fork 0

Disable overwrites when no-ansi is present, fixes #3612

pull/3041/merge
Jordi Boggiano 2015-01-05 16:17:15 +00:00
parent e172cd81a1
commit e0d36e19eb
2 changed files with 20 additions and 6 deletions

View File

@ -113,6 +113,14 @@ class ConsoleIO extends BaseIO
*/ */
public function overwrite($messages, $newline = true, $size = null) public function overwrite($messages, $newline = true, $size = null)
{ {
if (!$this->output->isDecorated()) {
if (!$messages) {
return;
}
return $this->write($messages, count($messages) === 1 || $newline);
}
// messages can be an array, let's convert it to string anyway // messages can be an array, let's convert it to string anyway
$messages = join($newline ? "\n" : '', (array) $messages); $messages = join($newline ? "\n" : '', (array) $messages);

View File

@ -58,21 +58,27 @@ class ConsoleIOTest extends TestCase
->method('write') ->method('write')
->with($this->equalTo('something (<question>strlen = 23</question>)')); ->with($this->equalTo('something (<question>strlen = 23</question>)'));
$outputMock->expects($this->at(1)) $outputMock->expects($this->at(1))
->method('write') ->method('isDecorated')
->with($this->equalTo(str_repeat("\x08", 23)), $this->equalTo(false)); ->willReturn(true);
$outputMock->expects($this->at(2)) $outputMock->expects($this->at(2))
->method('write') ->method('write')
->with($this->equalTo('shorter (<comment>12</comment>)'), $this->equalTo(false)); ->with($this->equalTo(str_repeat("\x08", 23)), $this->equalTo(false));
$outputMock->expects($this->at(3)) $outputMock->expects($this->at(3))
->method('write') ->method('write')
->with($this->equalTo(str_repeat(' ', 11)), $this->equalTo(false)); ->with($this->equalTo('shorter (<comment>12</comment>)'), $this->equalTo(false));
$outputMock->expects($this->at(4)) $outputMock->expects($this->at(4))
->method('write') ->method('write')
->with($this->equalTo(str_repeat("\x08", 11)), $this->equalTo(false)); ->with($this->equalTo(str_repeat(' ', 11)), $this->equalTo(false));
$outputMock->expects($this->at(5)) $outputMock->expects($this->at(5))
->method('write') ->method('write')
->with($this->equalTo(str_repeat("\x08", 12)), $this->equalTo(false)); ->with($this->equalTo(str_repeat("\x08", 11)), $this->equalTo(false));
$outputMock->expects($this->at(6)) $outputMock->expects($this->at(6))
->method('isDecorated')
->willReturn(true);
$outputMock->expects($this->at(7))
->method('write')
->with($this->equalTo(str_repeat("\x08", 12)), $this->equalTo(false));
$outputMock->expects($this->at(8))
->method('write') ->method('write')
->with($this->equalTo('something longer than initial (<info>34</info>)')); ->with($this->equalTo('something longer than initial (<info>34</info>)'));