Skip to content

Commit

Permalink
[Console] Fix autocomplete multibyte input support
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyweb committed Nov 23, 2019
1 parent 814bdeb commit d67c7ea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Symfony/Component/Console/Helper/QuestionHelper.php
Expand Up @@ -264,7 +264,7 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu
} elseif ("\177" === $c) { // Backspace Character
if (0 === $numMatches && 0 !== $i) {
--$i;
$fullChoice = substr($fullChoice, 0, -1);
$fullChoice = mb_substr($fullChoice, 0, -1);
// Move cursor backwards
$output->write("\033[1D");
}
Expand All @@ -278,7 +278,7 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu
}

// Pop the last character off the end of our string
$ret = substr($ret, 0, $i);
$ret = mb_substr($ret, 0, $i);
} elseif ("\033" === $c) {
// Did we read an escape sequence?
$c .= fread($inputStream, 2);
Expand All @@ -304,7 +304,7 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu
$remainingCharacters = substr($ret, \strlen(trim($this->mostRecentlyEnteredValue($fullChoice))));
$output->write($remainingCharacters);
$fullChoice .= $remainingCharacters;
$i = \strlen($fullChoice);
$i = mb_strlen($fullChoice);
}

if ("\n" === $c) {
Expand Down

0 comments on commit d67c7ea

Please sign in to comment.