Skip to content

Commit f9f8a88

Browse files
bug #62813 [Console] Fix EofShortcut instruction when using a modern terminal on Windows (fperxas)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [Console] Fix EofShortcut instruction when using a modern terminal on Windows | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #62514 | License | MIT On `SymfonyQuestionHelper` use the `isDecoratedFlag` instead of the PHP_OS_FAMILY. `@nicolas`-grekas suggested to use `StreamOutput::hasColorSupport()`. As it is a protected method i thought we could use the `OutputInterface::isDecorated` flag which is constructed from `StreamOutput` like this: `$decorated ??= $this->hasColorSupport();` Please review if it is a correct decision :) Commits ------- 2cac8785e5f [Console] Fix EofShortcut instruction when using a modern terminal on Windows
2 parents 9b0f9e1 + b5d397f commit f9f8a88

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Helper/SymfonyQuestionHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function writePrompt(OutputInterface $output, Question $question)
3434
$default = $question->getDefault();
3535

3636
if ($question->isMultiline()) {
37-
$text .= \sprintf(' (press %s to continue)', $this->getEofShortcut());
37+
$text .= \sprintf(' (press %s to continue)', $this->getEofShortcut($output));
3838
}
3939

4040
switch (true) {
@@ -98,9 +98,9 @@ protected function writeError(OutputInterface $output, \Exception $error)
9898
parent::writeError($output, $error);
9999
}
100100

101-
private function getEofShortcut(): string
101+
private function getEofShortcut(OutputInterface $output): string
102102
{
103-
if ('Windows' === \PHP_OS_FAMILY) {
103+
if ('\\' === \DIRECTORY_SEPARATOR && !$output->isDecorated()) {
104104
return '<comment>Ctrl+Z</comment> then <comment>Enter</comment>';
105105
}
106106

0 commit comments

Comments
 (0)