-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | yes |
Symfony version | 3.2.4 |
My situation is as follows:
I have a console application that uses a ChoiceQuestion with version numbers as values. Rendered the question looks like this:
[0]: 3.0.0
[1]: 2.2.0
[2]: 2.1.3
If I select option "2" I'll get "2.2.0", because the value gets autocompleted.
It even fails with associative arrays:
[a]: berlin
[b]: copenhagen
[c]: amsterdam
If I select "b", I get "a", the key of the first option, as its value is found by the autocompleter.
Here is a testcase to demonstrate the behaviour:
public function testAmbiguousKeyFromChoicelist()
{
$possibleChoices = array(
'a' => 'berlin',
'b' => 'copenhagen',
'c' => 'amsterdam',
);
$dialog = new QuestionHelper();
$helperSet = new HelperSet(array(new FormatterHelper()));
$dialog->setHelperSet($helperSet);
$question = new ChoiceQuestion('Please select the environment to load', $possibleChoices);
$question->setMaxAttempts(1);
$answer = $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream("b\n")), $this->createOutputInterface(), $question);
$this->assertSame("b", $answer);
}
A possible solutions could be:
- Do not consider keys as autocomplete values (so keys must match exactly)
- Do consider keys as autocomplete values, but the take precedence over values
My preference would be the first option.