Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public function cleanupSemantic()
)));
$diffs[$pointer - 1] = array(
self::INSERT,
mb_substr($insertion, 0, $overlap_length2),
mb_substr($insertion, 0, -$overlap_length2),
);
$diffs[$pointer + 1] = array(
self::DELETE,
Expand Down
13 changes: 13 additions & 0 deletions tests/DiffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,19 @@ public function testCleanupSemantic()
), $this->d->getChanges());
}

public function testLineModePreservesTextsAfterReverseOverlap()
{
$overlap = str_repeat('x', Diff::LINEMODE_THRESOLD - 2);
$source = $overlap . 'old';
$destination = 'new' . $overlap;

// Skip half-match so the smallest possible input reaches line-mode.
$this->d->setTimeout(0)->main($source, $destination, true);

$this->assertSame($source, $this->d->text1());
$this->assertSame($destination, $this->d->text2());
}

public function testCleanupEfficiency()
{
// Cleanup operationally trivial equalities.
Expand Down