Skip to content

Commit

Permalink
Report Full: iterate on line wrapping bug fix [2]
Browse files Browse the repository at this point in the history
Prevent inconsistency in handling of single-line vs multi-line length calculation.

Co-authored-by: Brad Jorsch <[email protected]>
  • Loading branch information
jrfnl and anomiex committed Dec 11, 2023
1 parent 3577799 commit b9dd7db
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Reports/Full.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,

if ($showSources === true) {
$lastMsg = $errorMsg;
$startPosLastLine = strrpos($errorMsg, $paddingLine2.$beforeMsg);
$startPosLastLine = strrpos($errorMsg, PHP_EOL.$paddingLine2.$beforeMsg);
if ($startPosLastLine !== false) {
// Message is multiline.
$lastMsg = substr($errorMsg, ($startPosLastLine + strlen($paddingLine2.$beforeMsg)));
// Message is multiline. Grab the text of last line of the message, including the color codes.
$lastMsg = substr($errorMsg, ($startPosLastLine + strlen(PHP_EOL.$paddingLine2)));
}

// When show sources is used, the message itself will be bolded, so we need to correct the length.
Expand Down

0 comments on commit b9dd7db

Please sign in to comment.