File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,9 @@ private static function initDimensions(): void
5555 $ consoleMode = self ::getConsoleMode ();
5656
5757 if ('\\' === \DIRECTORY_SEPARATOR ) {
58- if (\preg_match ('#^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$# ' , \trim (\getenv ('ANSICON ' )), $ matches )) {
59- self ::$ width = (int ) $ matches [1 ];
58+ $ width = self ::getAnsiconWidth ();
59+ if ($ width !== null ) {
60+ self ::$ width = $ width ;
6061 } elseif (! self ::hasVt100Support () && self ::hasSttyAvailable ()) {
6162 self ::initDimensionsUsingStty ();
6263 } elseif ($ consoleMode ) {
@@ -123,4 +124,17 @@ private static function readFromProcess(string $command): ?string
123124 \proc_close ($ process );
124125 return $ info ;
125126 }
127+
128+ private static function getAnsiconWidth (): ?int
129+ {
130+ if (!is_string (\getenv ('ANSICON ' ))) {
131+ return null ;
132+ }
133+
134+ if (\preg_match ('#^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$# ' , \trim (\getenv ('ANSICON ' )), $ matches )) {
135+ return (int ) $ matches [1 ];
136+ }
137+
138+ return null ;
139+ }
126140}
You can’t perform that action at this time.
0 commit comments