-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Section always writes with a newline #37304
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
Hey, thanks for your report! |
Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3 |
Judging from the code It seems that the issue is still present. I'll take a deeper look later today. |
I can confirm this behavior still exists at symfony/console 5.2 |
PR welcome! |
I'm currently working on the section output and am likely able to fix/change this accordingly: #41266 However, the docs currently define the behaviour to kind of be like this: |
Hey, thanks for your report! |
Friendly reminder that this issue exists. If I don't hear anything I'll close this. |
I use a /** @var \Symfony\Component\Console\Output\ConsoleOutputInterface $output */
$section = $output->section();
$buffer = new BufferedOutput();
for ($i = 0; $i < 100; $i++) {
$buffer->write('Element ' . (string) $i, false);
$bufferedData = $buffer->fetch();
$section->overwrite($bufferedData);
$buffer->write($bufferedData);
} |
Hey, thanks for your report! |
PR welcome on the lowest branch where the bug exists (with test case please!) |
Add PHPUnit tests to check write() vs. writeln() in sections
…agendra-ishaya) This PR was submitted for the 4.4 branch but it was merged into the 6.2 branch instead. Discussion ---------- [Console] Fix console section output without newline | Q | A | ------------- | --- | Branch | 4.4 | Bug fix | yes | New feature | no | Deprecations | no | Tickets | Fix #37304 | License | MIT | Doc PR | n/a As described in #37304, when writing to a output section, a newline would automatically be added, inrespective wether using `write()` or `writeln()`. This PR fixes said behaviour. Lines can now be appended to. Commits ------- 92d9382 [Console] Fix forced linebreak in output sections (fixes #37304)
If you stumble upon this issue, please note that while this was introduced in 4.1 and considered a bug, the patch was considered a new feature and hence applied only to 6.2 (refer to the conversation of #46812 for further details). |
Symfony version(s) affected: 4.1.0 and higher
Description
ConsoleSectionOutput
always writes with a newline even if explicitly set to false, eg.:$section->write('foo', false);
sinceisDecorated()
always returnstrue
by default. Output behaves correctly if$section->setDecorated(false);
but all decoration is automatically gone which should not be the case.How to reproduce
Possible Solution
$newline
argument value should be taken into account in this method: https://github.com/symfony/console/blob/v4.1.0/Output/ConsoleSectionOutput.php#L97Once confirmed I'm more than happy to create a PR that fixes it 🙂
The text was updated successfully, but these errors were encountered: