diff --git a/src/Utils.php b/src/Utils.php index 2f9efcd5..c22a980e 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -116,6 +116,9 @@ public static function isGithubActions(): bool return self::isDocker() && Env::bool('GITHUB_ACTIONS'); } + /** + * Autodetect the width of the terminal. + */ public static function autoDetectTerminalWidth(): int { static $maxAutoDetected; // Execution optimization @@ -126,7 +129,8 @@ public static function autoDetectTerminalWidth(): int } elseif (self::isDocker()) { $maxAutoDetected = 140; } else { - // Fallback value is 80 + // Fallback to 80 if the terminal width cannot be determined. + // env.COLUMNS_TEST usually not defined, so we use it only for testing purposes. $maxAutoDetected = Env::int('COLUMNS_TEST', Cli::getNumberOfColumns()); } } diff --git a/src/Validators/ErrorSuite.php b/src/Validators/ErrorSuite.php index d4c9917b..fdcc2157 100644 --- a/src/Validators/ErrorSuite.php +++ b/src/Validators/ErrorSuite.php @@ -203,12 +203,8 @@ private static function getTableSize(): array 'reserve' => 3, // So that the table does not rest on the very edge of the terminal. Just in case. ]; - // Fallback to 80 if the terminal width cannot be determined. - // env.COLUMNS_TEST usually not defined, so we use it only for testing purposes. - $maxAutoDetected = Utils::autoDetectTerminalWidth(); - $maxWindowWidth = Vars::limit( - $maxAutoDetected, + Utils::autoDetectTerminalWidth(), $floatingSizes['min'], $floatingSizes['max'], ) - $floatingSizes['reserve'];