8000 [Console] Do no preprend empty line if the buffer is empty · symfony/symfony@a9f1250 · GitHub
[go: up one dir, main page]

Skip to content

Commit a9f1250

Browse files
committed
[Console] Do no preprend empty line if the buffer is empty
1 parent aee9ea5 commit a9f1250

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

src/Symfony/Component/Console/Style/SymfonyStyle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ private function autoPrependText(): void
375375
{
376376
$fetched = $this->bufferedOutput->fetch();
377377
// Prepend new line if last char isn't EOL:
378-
if (!str_ends_with($fetched, "\n")) {
378+
if ($fetched && !str_ends_with($fetched, "\n")) {
379379
$this->newLine();
380380
}
381381
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
use Symfony\Component\Console\Input\InputInterface;
4+
use Symfony\Component\Console\Output\OutputInterface;
5+
use Symfony\Component\Console\Style\SymfonyStyle;
6+
7+
// ensure that nested tags have no effect on the color of the '//' prefix
8+
return function (InputInterface $input, OutputInterface $output) {
9+
$output = new SymfonyStyle($input, $output);
10+
$output->text('Hello');
11+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello

src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_6.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
* Lorem ipsum dolor sit amet
32
* consectetur adipiscing elit
43

0 commit comments

Comments
 (0)
0