Fix missing diff output on large diffs

When there is a large diff chunk, match_lines() will skip running the difflib.Differ.compare(). However this causes the following issues:

  • It does not empty the self.buf buffer. This means that all future calls to match_lines() for that file will always be too large. So effectively no more diffs from the file get output.

  • It outputs a debug message, but does not output anything to the side-by-side diff, so a user looking at the side-by-side diff may be misled into thinking the rest of the file has no differences.

We can fix these issue by falling back to a lazy line-by-line diff. This produces suboptimal output, but it runs in linear O(n) time while providing some form of output. We include a comment in the diff so the user knows the following output is using a lazy diff algorithm.

Merge request reports

Loading