-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Question helper is behaving differently when inside a Section #47411
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
Comments
Thanks for the report, looks like a bug indeed. Are you wiling to investigate and try to send a fix? |
I can try |
Sorry I didn't had time to work on this yet. :-( |
@bigfoot90 just a question, did you have this problems on a unix or on a windows environment? I can only reproduce this on windows. /cc @chalasr what I saw on windows is again a lineending bug:
Changing this php PHP_EOL would fix it (for windows env)
And affected versions are then symfony 4.4+ |
@maxbeckers I'm on Ubuntu system |
@bigfoot90 you're right, there was sth wrong in my vendors. And the enter of the input is the problem you mentioned. |
…in section (maxbeckers) (chalasr) This PR was merged into the 6.1 branch. Discussion ---------- [Console] Revert "bug #48089 Fix clear line with question in section (maxbeckers) This reverts commit caffee8, reversing changes made to f14901e. | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | / | License | MIT | Doc PR | - The tests added in #48089 break on branch 6.2, and after checking the fix on both 6.1 and 6.2 based on the reproducer from #47411, I feel like the behavior is still not the expected one. I propose to revert for now, hope we can fix this bug homogeneously in another PR. Commits ------- 30caa8d Revert "bug #48089 [Console] Fix clear line with question in section (maxbeckers)"
Thank you 🙏 |
The new changes of the behavior seem to be related to #37304 ... This seems to be related to
Because there is for newline always true ... setting this to the parameter $newline seems to fix most of the problem. I could set it to $newline and create a PR, But I don't know the effects of this change, because it will have any reason that it's not $newline for now I guess.
@chalasr do you have any Idea, why it's not |
This PR was merged into the 6.2 branch. Discussion ---------- [Console] fix clear of section with question | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #47411 | License | MIT | Doc PR | n/a This PR fixes the problems to clear a section with a question included. Example Code: ``` protected function execute(InputInterface $input, OutputInterface $output) { $section1 = $output->section(); $io = new SymfonyStyle($input, $section1); $output->writeln("foo"); $countdown = 3; while ($countdown > 0) { $section1->clear(); $io->writeln('start ' . $countdown); $io->write('foo'); $io->write(' and bar'.\PHP_EOL); $givenAnswer = $io->ask('Dummy question?'); $section1->write('bar'); $countdown--; } return self::SUCCESS; } ``` Output loop 1:  Output loop 1:  There was already a fix #48089 to be merged in 6.1, but the problem was that there were some changes in 6.2, so it was not possible to merge it into 6.2. So this fix is only working for 6.2, but perhaps we could find a solution as well for the older versions. But because of the changes of console it was not possible to find a solution working for all versions. `@chalasr` this fix is still with the newline always `true` https://github.com/symfony/symfony/blob/4cf9855debc26e4323429ac8d87f02df582e2893/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php#L181 A change of the newline to `$newline` would change the behavior. Maybe we could change that in symfony 7. To make it easier to test is here a zip with 2 testcommands in the root and the changed vendors. [test-48089.zip](https://github.com/symfony/symfony/files/10360423/test-48089.zip) Commits ------- f4c5518 [Console] fix clear of section with question
Symfony version(s) affected
6.1.4
Description
The question helper is going onto a new line when used inside a Section, therefore section cannot rewrite correctly
How to reproduce
Question helper only
Code
Section helper only
Code
Both combined
Code
Expected
Final output should be
The text was updated successfully, but these errors were encountered: