Skip to content

Commit

Permalink
Revert "bug #48089 [Console] Fix clear line with question in section …
Browse files Browse the repository at this point in the history
…(maxbeckers)"

This reverts commit caffee8d62e7f998fcf6116ca128b8343017f3d2, reversing
changes made to f14901e3a4343bb628ff0f7e5f213752381a069e.
  • Loading branch information
chalasr committed Dec 16, 2022
1 parent 578809f commit c649f33
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 50 deletions.
8 changes: 0 additions & 8 deletions Output/ConsoleSectionOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,6 @@ public function addContent(string $input)
}
}

/**
* @internal
*/
public function incrementLines()
{
++$this->lines;
}

/**
* {@inheritdoc}
*/
Expand Down
6 changes: 0 additions & 6 deletions Style/SymfonyStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\ConsoleSectionOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\TrimmedBufferOutput;
use Symfony\Component\Console\Question\ChoiceQuestion;
Expand Down Expand Up @@ -351,11 +350,6 @@ public function askQuestion(Question $question): mixed
if ($this->input->isInteractive()) {
$this->newLine();
$this->bufferedOutput->write("\n");
if ($this->output instanceof ConsoleSectionOutput) {
// add one line more to the ConsoleSectionOutput because of the `return` to submit the input
// this is relevant when a `ConsoleSectionOutput::clear` is called.
$this->output->incrementLines();
}
}

return $answer;
Expand Down
36 changes: 0 additions & 36 deletions Tests/Style/SymfonyStyleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\Input;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\ConsoleSectionOutput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Console\Tester\CommandTester;

Expand Down Expand Up @@ -183,38 +181,4 @@ public function testMemoryConsumption()

$this->assertSame(0, memory_get_usage() - $start);
}

public function testAskAndClearExpectFullSectionCleared()
{
$answer = 'Answer';
$inputStream = fopen('php://memory', 'r+');
fwrite($inputStream, $answer.\PHP_EOL);
rewind($inputStream);
$input = $this->createMock(Input::class);
$sections = [];
$output = new ConsoleSectionOutput(fopen('php://memory', 'r+', false), $sections, StreamOutput::VERBOSITY_NORMAL, true, new OutputFormatter());
$input
->method('isInteractive')
->willReturn(true);
$input
->method('getStream')
->willReturn($inputStream);

$style = new SymfonyStyle($input, $output);

$style->write('foo');
$givenAnswer = $style->ask('Dummy question?');
$output->write('bar');
$output->clear();

rewind($output->getStream());
$this->assertEquals($answer, $givenAnswer);
$this->assertEquals(
'foo'.\PHP_EOL. // write foo
\PHP_EOL.\PHP_EOL.\PHP_EOL." \033[32mDummy question?\033[39m:".\PHP_EOL.' > '.\PHP_EOL.\PHP_EOL.\PHP_EOL. // question
'bar'.\PHP_EOL. // write bar
"\033[10A\033[0J", // clear 10 lines (9 output lines and one from the answer input return)
stream_get_contents($output->getStream())
);
}
}

0 comments on commit c649f33

Please sign in to comment.