Skip to content

Commit

Permalink
Report Full: iterate on line wrapping bug fix [3]
Browse files Browse the repository at this point in the history
Don't hard code the color code length to prevent this breaking on potential future changes.

Co-authored-by: Brad Jorsch <[email protected]>
  • Loading branch information
jrfnl and anomiex committed Dec 11, 2023
1 parent b9dd7db commit 245efc5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Reports/Full.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
$beforeMsg = "\033[1m";
$afterMsg = "\033[0m";
}
$beforeAfterLength = strlen($beforeMsg.$afterMsg);

foreach ($report['messages'] as $line => $lineErrors) {
foreach ($lineErrors as $column => $colErrors) {
Expand Down Expand Up @@ -150,7 +151,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;
Expand Down

0 comments on commit 245efc5

Please sign in to comment.