mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
LibDiff: Flush leftover hunks at the end
This change makes sure that we arrive at the end of the "DP-matrix" and flush any leftover hunks to get a complete diff result.
This commit is contained in:
parent
33043f269d
commit
4737fc2485
1 changed files with 10 additions and 0 deletions
|
@ -106,6 +106,16 @@ Vector<Hunk> from_text(StringView old_text, StringView new_text)
|
|||
flush_hunk();
|
||||
}
|
||||
}
|
||||
|
||||
while (i < old_lines.size() && new_lines.size() > 0) {
|
||||
update_hunk(i, new_lines.size() - 1, Direction::Right); // Remove a line
|
||||
++i;
|
||||
}
|
||||
while (j < new_lines.size() && old_lines.size() > 0) {
|
||||
update_hunk(old_lines.size() - 1, j, Direction::Down); // Add a line
|
||||
++j;
|
||||
}
|
||||
|
||||
flush_hunk();
|
||||
|
||||
return hunks;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue