Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9270395

Browse files
committed
[Console] Fix testing multiline question
1 parent 1cf3e65 commit 9270395

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,12 +527,16 @@ private function readInput($inputStream, Question $question): string|false
527527
$ret = '';
528528
$cp = $this->setIOCodepage();
529529
while (false !== ($char = fgetc($multiLineStreamReader))) {
530-
if (\PHP_EOL === "{$ret}{$char}") {
530+
if ("\x4" === $char || \PHP_EOL === "{$ret}{$char}") {
531531
break;
532532
}
533533
$ret .= $char;
534534
}
535535

536+
if (stream_get_meta_data($inputStream)['seekable']) {
537+
fseek($inputStream, ftell($multiLineStreamReader));
538+
}
539+
536540
return $this->resetIOCodepage($cp, $ret);
537541
}
538542

src/Symfony/Component/Console/Tester/TesterTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ private static function createStream(array $inputs)
169169

170170
foreach ($inputs as $input) {
171171
fwrite($stream, $input.\PHP_EOL);
172+
173+
if (str_contains($input, \PHP_EOL)) {
174+
fwrite($stream, "\x4");
175+
}
172176
}
173177

174178
rewind($stream);

0 commit comments

Comments
 (0)