Skip to content

Commit 6fcafe1

Browse files
committed
Fix #83 - Lines not properly marked
If a line is different at the other version from the first to the last character, the line isn't marked when inlineMarking is set to CHANGE_LEVEL_LINE.
1 parent 0bd0bd2 commit 6fcafe1

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

lib/jblond/Diff/Renderer/MainRenderer.php

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -310,26 +310,24 @@ private function markOuterChange(array &$oldText, array &$newText, int $startOld
310310

311311
// Determine the start and end position of the line difference.
312312
[$start, $end] = $this->getOuterChange($oldString, $newString);
313-
if ($start != 0 || $end != 0) {
314-
// Changes between the lines exist.
315-
// Add markers around the changed character sequence in the old string.
316-
$sequenceEnd = mb_strlen($oldString) + $end;
317-
$oldString =
318-
mb_substr($oldString, 0, $start) . "\0" .
319-
mb_substr($oldString, $start, $sequenceEnd - $start) . "\1" .
320-
mb_substr($oldString, $sequenceEnd);
321-
322-
// Add markers around the changed character sequence in the new string.
323-
$sequenceEnd = mb_strlen($newString) + $end;
324-
$newString =
325-
mb_substr($newString, 0, $start) . "\0" .
326-
mb_substr($newString, $start, $sequenceEnd - $start) . "\1" .
327-
mb_substr($newString, $sequenceEnd);
328-
329-
// Overwrite the strings in the old and new text so the changed lines include the markers.
330-
$oldText[$startOld + $iterator] = $oldString;
331-
$newText[$startNew + $iterator] = $newString;
332-
}
313+
// Changes between the lines exist.
314+
// Add markers around the changed character sequence in the old string.
315+
$sequenceEnd = mb_strlen($oldString) + $end;
316+
$oldString
317+
= mb_substr($oldString, 0, $start) . "\0" .
318+
mb_substr($oldString, $start, $sequenceEnd - $start) . "\1" .
319+
mb_substr($oldString, $sequenceEnd);
320+
321+
// Add markers around the changed character sequence in the new string.
322+
$sequenceEnd = mb_strlen($newString) + $end;
323+
$newString
324+
= mb_substr($newString, 0, $start) . "\0" .
325+
mb_substr($newString, $start, $sequenceEnd - $start) . "\1" .
326+
mb_substr($newString, $sequenceEnd);
327+
328+
// Overwrite the strings in the old and new text so the changed lines include the markers.
329+
$oldText[$startOld + $iterator] = $oldString;
330+
$newText[$startNew + $iterator] = $newString;
333331
}
334332
}
335333

0 commit comments

Comments
 (0)