Skip to content

Commit 245efc5

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 245efc5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Reports/Full.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
121121
$beforeMsg = "\033[1m";
122122
$afterMsg = "\033[0m";
123123
}
124+
$beforeAfterLength = strlen($beforeMsg.$afterMsg);
124125

125126
foreach ($report['messages'] as $line => $lineErrors) {
126127
foreach ($lineErrors as $column => $colErrors) {
@@ -150,7 +151,7 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
150151
// Add space + source suffix length.
151152
$lastMsgPlusSourceLength += (1 + strlen($sourceSuffix));
152153
// Correct for the color codes.
153-
$lastMsgPlusSourceLength -= 8;
154+
$lastMsgPlusSourceLength -= $beforeAfterLength;
154155

155156
if ($lastMsgPlusSourceLength > $maxErrorSpace) {
156157
$errorMsg .= PHP_EOL.$paddingLine2.$sourceSuffix;

0 commit comments

Comments
 (0)