Skip to content

Commit 0ba5736

Browse files
jrfnlanomiex
andcommitted
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 <anomie@users.sourceforge.net>
1 parent b9dd7db commit 0ba5736

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Reports/Full.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
122122
$afterMsg = "\033[0m";
123123
}
124124

125+
$beforeAfterLength = strlen($beforeMsg.$afterMsg);
126+
125127
foreach ($report['messages'] as $line => $lineErrors) {
126128
foreach ($lineErrors as $column => $colErrors) {
127129
foreach ($colErrors as $error) {
@@ -150,7 +152,7 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
150152
// Add space + source suffix length.
151153
$lastMsgPlusSourceLength += (1 + strlen($sourceSuffix));
152154
// Correct for the color codes.
153-
$lastMsgPlusSourceLength -= 8;
155+
$lastMsgPlusSourceLength -= $beforeAfterLength;
154156

155157
if ($lastMsgPlusSourceLength > $maxErrorSpace) {
156158
$errorMsg .= PHP_EOL.$paddingLine2.$sourceSuffix;

0 commit comments

Comments
 (0)