If we skip some nodes inside a list whose delimiters are unchanged, we
need to mark the outer list as unchanged.
Split ChangeState::Unchanged into UnchangedNode and UnchangedDelimiter
to make this clearer, and add a test.
After we've aligned lines based on diff results, we have intermediate
lines that we need to align somehow. Previously, we'd just take them
in order, aligning the first on the LHS with the first on the RHS and
so on.
If the intermediate lines start or end with a sequence of blank lines,
prefer aligning the blank lines. If we have both, arbitrarily choose
the ending blank lines.
This has produced better results in many of the sample files, although
in the case of slow_before.rs we've just changed from a leading blank
line alignment to a trailing blank line alignment.
Previously we were assuming that the first/last line pairs in a hunk
contained the earliest/latest lines on both sides. This isn't true
when there are no common items between the lines.
This fixes some display issues in load_before/after.js, but include a
new integration test that is smaller and easier to eyeball.
Fixes#133
In #153 a user reported difftastic never terminated on a 140,000
file. This was due to the diff crate using a very large amount of time
and memory.
The diff crate does not use Myers' algorithm, which has a
divide-and-conquer approach using snakes:
https://blog.jcoglan.com/2017/03/22/myers-diff-in-linear-space-theory/
wu-diff does implement Myer's algorithm and performs much better on
these large files.
This reverts commit 7544874a55. It turns
out there are cases where this is still necessary (see new sample
file). It's also performance neutral.
This bug became more obvious with the recent 'skip unchanged'
optimisations. The optimisation changed the number of preceeding nodes and
exposed this bug more often.
Introduce a new type EnteredDelimiter that tracks entering/leaving
list nodes. The PopEither and PopBoth cases reflect the choices more
accurately than a 2-tuple of options.
This is a performance hit (slow_before.rs runtime has increased by
49%) but it's important for diff correctness.
Fixes#147
Helps with #148. On my machine this changes slow_after.rs from 4.4 to
3.4 seconds, but only reduced instruction count from 12.8B to 10.4B.
The one changed case in sample_files/ is more granular and more
readable.