Closed mcmire closed 5 years ago
Conceptually, we need to extend Diff::LCS so that if a value was changed (i.e. a deletion and addition occurred at the same position), and that value is an array, we need to descend into that array and perform LCS on it. If it's a hash, we need to do what we normally do.
Currently if you have two arrays:
and you diff them, the differ will tell you this, basically:
Now, ideally, this is not very helpful. We should be able to figure out that "1" and "2" were inserted before "a" and that "c" and "d" were removed. So maybe the output would be exactly that:
Notice that we aren't listing the array indices anymore, since those are no longer meaningful.
This actually sounds like a proper use case for the LCS algorithm.