Commit fc0e346
committed
bug #48897 [Console] fix clear of section with question (maxbeckers)
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
-------
f4c551805b [Console] fix clear of section with questionFile tree
3 files changed
+59
-1
lines changed- Output
- Style
- Tests/Style
3 files changed
+59
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
152 | 162 | | |
153 | 163 | | |
154 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
298 | 299 | | |
299 | 300 | | |
300 | 301 | | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
301 | 307 | | |
302 | 308 | | |
303 | 309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
184 | 226 | | |
0 commit comments