From 0ba5736e423c8ba3dafe3ed382aa58b91cc5c315 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 11 Dec 2023 01:25:03 +0100 Subject: [PATCH] Report Full: iterate on line wrapping bug fix [3] Don't hard code the color code length to prevent this breaking on potential future changes. Co-authored-by: Brad Jorsch --- src/Reports/Full.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Reports/Full.php b/src/Reports/Full.php index 3f99e976ea..ee2b5af203 100644 --- a/src/Reports/Full.php +++ b/src/Reports/Full.php @@ -122,6 +122,8 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, $afterMsg = "\033[0m"; } + $beforeAfterLength = strlen($beforeMsg.$afterMsg); + foreach ($report['messages'] as $line => $lineErrors) { foreach ($lineErrors as $column => $colErrors) { foreach ($colErrors as $error) { @@ -150,7 +152,7 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, // Add space + source suffix length. $lastMsgPlusSourceLength += (1 + strlen($sourceSuffix)); // Correct for the color codes. - $lastMsgPlusSourceLength -= 8; + $lastMsgPlusSourceLength -= $beforeAfterLength; if ($lastMsgPlusSourceLength > $maxErrorSpace) { $errorMsg .= PHP_EOL.$paddingLine2.$sourceSuffix;