8000 [Console] Fix #21789 : CLI Windows autcompletion for ChoiceQuestion function by RonanSauvage · Pull Request #24716 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] Fix #21789 : CLI Windows autcompletion for ChoiceQuestion function #24716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

RonanSauvage
Copy link
@RonanSauvage RonanSauvage commented Oct 28, 2017
Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #21789
License MIT
Doc PR no

[Console] fixed ChoiceQuestion behavior for Win CLI

WIP :
[ ] Unit test break

This PR change CLI Windows behavior for autocompletion in Console->ChoiceQuestion.

In Win CLI you can't see autocompletion so your results can be false if in your choices you've one first symbol (letter or number) equals to your array_keys.
This is described in bug topic.

In this PR, I've just removed autocompletion for Win CLI.

@RonanSauvage RonanSauvage changed the title Fix #21789 : CLI Windows autcompletion for ChoiceQuestion function [Console] Fix #21789 : CLI Windows autcompletion for ChoiceQuestion function Oct 28, 2017
@@ -114,7 +114,7 @@ public function doAsk(OutputInterface $output, Question $question)
$inputStream = $this->inputStream ?: STDIN;
$autocomplete = $question->getAutocompleterValues();

if (null === $autocomplete || !$this->hasSttyAvailable()) {
if ((null === $autocomplete || self::OS_WIN == $this->getOSTerminal()) || !$this->hasSttyAvailable()) {
Copy link
Member
@nicolas-grekas nicolas-grekas Oct 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding new const + public method is a new feature.
Here, it's not needed, just do as we do everywhere else: '\\' === \DIRECTORY_SEPARATOR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or use a private method here instead of putting this in the base Helper class

@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Oct 28, 2017
@nicolas-grekas
Copy link
Member

Note that tests are failing with this change.

Status: needs work

@RonanSauvage
Copy link
Author

Thx @nicolas-grekas for your comment. I've read more information and I dont know if this behavior is caused by OS or by shell version (like git bash - not working, or cygwin). Have u got any suggestion or idea on that ?

@chalasr chalasr added the Console label Nov 1, 2017
public function getOSTerminal()
{
switch (true) {
case stristr(PHP_OS, 'DAR'): return self::OS_OSX;
Copy link
Member
@keradus keradus Dec 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this code gonna survive as private method:
PHP_OS_FAMILY could be better choice

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On PHP 5.3?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't Sf use it's own polyfill ?

@RonanSauvage
Copy link
Author

Hello, 6 months later my question is : Can we say autocompletion does not work on Windows prompt ? (Gitbash & co ? )

If that is the case, can we afford add one requirement in Test class ? Like in QuestionHelperTest line 197 to exclude autocompletion test in Windows environment ? I dont know if it's leggit in PR practices & fix strategy ?

@nicolas-grekas
Copy link
Member

Instead of working around in some adhoc way, I'd suggest this should be not autocompleted on any platform. See #26875

@nicolas-grekas
Copy link
Member

Replaced by #26875
thank you @RonanSauvage for giving it a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0