in src/Diff.php [66:103]
final public function getDiff(): vec<DiffOp<this::TContent>> {
$a = $this->a;
$b = $this->b;
$moves = Vec\reverse($this->getMoves());
$diff = vec[];
$prev = tuple(0, 0);
foreach ($moves as list($from, $to)) {
invariant($from === $prev, 'Missed a step');
list($x, $y) = $from;
$prev = $to;
if ($to === tuple($x + 1, $y + 1)) {
$diff[] =
new DiffKeepOp($a[$x]['pos'], $b[$y]['pos'], $a[$x]['content']);
continue;
}
if ($to === tuple($x + 1, $y)) {
$diff[] = new DiffDeleteOp($a[$x]['pos'], $a[$x]['content']);
continue;
}
if ($to === tuple($x, $y + 1)) {
$diff[] = new DiffInsertOp($b[$y]['pos'], $b[$y]['content']);
continue;
}
invariant_violation(
'invalid move: (%d, %d) => (%d, %d)',
$from[0],
$from[1],
$to[0],
$to[1],
);
}
return $diff;
}