10000 [Console] Add support for parsing terminal width/height on localized … · symfony/symfony@d2231d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit d2231d8

Browse files
committed
[Console] Add support for parsing terminal width/height on localized windows, fixes #5742
1 parent 722c19b commit d2231d8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ protected function getTerminalWidth()
853853
return preg_replace('{^(\d+)x.*$}', '$1', $ansicon);
854854
}
855855

856-
if (preg_match('{columns:\s*(\d+)}i', $this->getConsoleMode(), $matches)) {
856+
if (preg_match('{^(\d+)x\d+$}i', $this->getConsoleMode(), $matches)) {
857857
return $matches[1];
858858
}
859859
}
@@ -875,7 +875,7 @@ protected function getTerminalHeight()
875875
return preg_replace('{^\d+x\d+ \(\d+x(\d+)\)$}', '$1', trim($ansicon));
876876
}
877877

878-
if (preg_match('{lines:\s*(\d+)}i', $this->getConsoleMode(), $matches)) {
878+
if (preg_match('{^\d+x(\d+)$}i', $this->getConsoleMode(), $matches)) {
879879
return $matches[1];
880880
}
881881
}
@@ -966,7 +966,7 @@ private function getSttyColumns()
966966
/**
967967
* Runs and parses mode CON if it's available, suppressing any error output
968968
*
969-
* @return string
969+
* @return string <width>x<height> or null if it could not be parsed
970970
*/
971971
private function getConsoleMode()
972972
{
@@ -982,7 +982,9 @@ private function getConsoleMode()
982982
fclose($pipes[2]);
983983
proc_close($process);
984984

985-
return $info;
985+
if (preg_match('{--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n}', $info, $matches)) {
986+
return $matches[2].'x'.$matches[1];
987+
}
986988
}
987989
}
988990

0 commit comments

Comments
 (0)
0