Fix myerss diff algorithm if first hit is a insert

This commit is contained in:
Tim 2025-04-23 02:20:54 +02:00
parent 4e16444d2f
commit ca7a093e55

View File

@ -62,8 +62,9 @@ class MyersDiff
$values[] = $b[$y];
$y++;
}
if ($solution[count($solution) - 1][0] === 'I') {
$solution[count($solution) - 1][1] = array_merge($solution[count($solution) - 1][1], $values);
$solutionKey = count($solution) - 1;
if ($solutionKey >= 0 && $solution[$solutionKey][0] === 'I') {
$solution[$solutionKey][1] = array_merge($solution[$solutionKey][1], $values);
} else {
$solution[] = ['I', $values];
}