gliese1337 / fast-myers-diff

MIT License
53 stars 8 forks source link

Explain in README the output of calcPatch #10

Closed caub closed 3 years ago

caub commented 3 years ago

For example:

> [...d.calcPatch('foo!!', 'fo1o')]
[ [ 2, 2, '1', 3 ], [ 3, 5, '', 4 ] ]

I guess [2, 2, '1', 3] is between 2nd and 2nd char of initial value (remove nothing), insert '1', (what is 3?)

then [ 3, 5, '', 4 ] is between 3rd and 5th, insert '' (so remove '!!'), there again what is 4?

Thanks for your project

make-github-pseudonymous-again commented 3 years ago

I believe you should not take the last item in consideration. Each tuple in calcPatch is a triple (deleteStart, deleteEnd, insert). The member insert is computed here. For some reason the fourth element is kept in the resulting tuple but I think it should not be taken into account.