Skip to content
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

Fix max width for multibyte keys in choice question #17314

Conversation

marek-pietrzak-tg
Copy link
Contributor

Fixes wrong key max width for ChoiceQuestion in multibyte strings

Before:
before

After:
after

To replicate you can use this code as an example:

namespace AppBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;

class QuesionCommand extends Command
{
    protected function configure()
    {
        $this->setName('app:question');
        $this->setDescription('Command for testing PR');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $helper = $this->getHelper('question');

        $question = new ChoiceQuestion('Choose something:',
            [
                'foo' => 'foo',
                'żółw' => 'bar',
                'łabądź' => 'baz',
                'известно' => 'lorem',
                'газета' => 'ipsum',
            ],
            0);

        $colour = $helper->ask($input, $output, $question);
        $output->writeln('you have chosen: ' . $colour);
    }
}
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #15368
License MIT
Doc PR -

@marek-pietrzak-tg marek-pietrzak-tg changed the title Fix max width for choice question Fix max width for multibyte keys in choice question Jan 8, 2016
@jakzal jakzal added the Console label Jan 8, 2016
@nicolas-grekas
Copy link
Member

👍
Status: reviewed

@fabpot
Copy link
Member

fabpot commented Jan 14, 2016

Thank you @mheki.

fabpot added a commit that referenced this pull request Jan 14, 2016
This PR was submitted for the 2.8 branch but it was merged into the 2.7 branch instead (closes #17314).

Discussion
----------

Fix max width for multibyte keys in choice question

Fixes wrong key max width for ChoiceQuestion in multibyte strings

Before:
![before](https://cloud.githubusercontent.com/assets/2435655/12203385/977e88c0-b626-11e5-9425-d497f84a9ab3.png)

After:
![after](https://cloud.githubusercontent.com/assets/2435655/12203390/9d9a0b4e-b626-11e5-8d4e-ba9290820778.png)

To replicate you can use this code as an example:
```
namespace AppBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;

class QuesionCommand extends Command
{
    protected function configure()
    {
        $this->setName('app:question');
        $this->setDescription('Command for testing PR');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $helper = $this->getHelper('question');

        $question = new ChoiceQuestion('Choose something:',
            [
                'foo' => 'foo',
                'żółw' => 'bar',
                'łabądź' => 'baz',
                'известно' => 'lorem',
                'газета' => 'ipsum',
            ],
            0);

        $colour = $helper->ask($input, $output, $question);
        $output->writeln('you have chosen: ' . $colour);
    }
}
```

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #15368
| License       | MIT
| Doc PR        | -

Commits
-------

5d2463b Fix max width for multibyte keys in choice question
@fabpot fabpot closed this Jan 14, 2016
This was referenced Jan 14, 2016
@fabpot fabpot mentioned this pull request Feb 3, 2016
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.

None yet

5 participants