Skip to content

Commit b9dd7db

Browse files
jrfnlanomiex
andcommitted
Report Full: iterate on line wrapping bug fix [2]
Prevent inconsistency in handling of single-line vs multi-line length calculation. Co-authored-by: Brad Jorsch <[email protected]>
1 parent 3577799 commit b9dd7db

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Reports/Full.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
137137

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

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

0 commit comments

Comments
 (0)