diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 84349cf3b608d..3f047e7202391 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -236,7 +236,7 @@ protected function writeError(OutputInterface $output, \Exception $error) */ private function autocomplete(OutputInterface $output, Question $question, $inputStream, callable $autocomplete): string { - $cursor = new Cursor($output); + $cursor = new Cursor($output, $inputStream); $fullChoice = ''; $ret = ''; @@ -265,7 +265,6 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu } elseif ("\177" === $c) { // Backspace Character if (0 === $numMatches && 0 !== $i) { --$i; - // Move cursor backwards $cursor->moveLeft(); $fullChoice = self::substr($fullChoice, 0, $i); @@ -354,16 +353,13 @@ function ($match) use ($ret) { } } - // Erase characters from cursor to end of line $cursor->clearLine(true); if ($numMatches > 0 && -1 !== $ofs) { - // Save cursor position $cursor->savePosition(); // Write highlighted text, complete the partially entered response $charactersEntered = \strlen(trim($this->mostRecentlyEnteredValue($fullChoice))); $output->write(''.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $charactersEntered)).''); - // Restore cursor position $cursor->restorePosition(); } }