From 2788f835764c365db58996f7302f3a1290794ce6 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 3 Nov 2016 13:32:15 +0300 Subject: [PATCH] Fixes #12879: Console progress bar was not working properly in Windows terminals --- framework/CHANGELOG.md | 1 + framework/helpers/BaseConsole.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 6a7ce36..869eada 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -22,6 +22,7 @@ Yii Framework 2 Change Log - Enh #12790: Added `scrollToErrorOffset` option for `ActiveForm` which adds ability to specify offset in pixels when scrolling to error (mg-code) - Enh #12748: Migration generator now tries to fetch reference column name for foreignKey from schema if it's not set explicitly (MKiselev) - Bug #4113: Error page stacktrace was generating links to private methods which are not part of the API docs (samdark) +- Bug #12879: Console progress bar was not working properly in Windows terminals (samdark, kids-return) 2.0.10 October 20, 2016 ----------------------- diff --git a/framework/helpers/BaseConsole.php b/framework/helpers/BaseConsole.php index 1e0b543..f826b45 100644 --- a/framework/helpers/BaseConsole.php +++ b/framework/helpers/BaseConsole.php @@ -968,7 +968,10 @@ class BaseConsole $info .= sprintf(' ETA: %d sec.', self::$_progressEta); } - $width -= 3 + static::ansiStrlen($info); + // Number extra characters outputted. These are opening [, closing ], and space before info + // Since Windows uses \r\n\ for line endings, there's one more in the case + $extraChars = static::isRunningOnWindows() ? 4 : 3; + $width -= $extraChars + static::ansiStrlen($info); // skipping progress bar on very small display or if forced to skip if ($width < 5) { static::stdout("\r$prefix$info ");