You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 21, 2022. It is now read-only.
Hello!
When you are looking for the end position while something was added to the end
of the text, then result will be the end of the new text. Here is a test:
assertEquals(3, dmp.diff_xIndex([[DIFF_EQUAL, 'foo'], [DIFF_INSERT, 'bar']], 3));
The result will be 6.
My understanding of locations within text is that it's just like a cursor. For
example:
|foo - position 0
f|oo - position 1
fo|o - position 2
foo| - position 3
I've tried to fix it by myself and have changed > comparison to >= in
https://code.google.com/p/google-diff-match-patch/source/browse/trunk/javascript
/diff_match_patch_uncompressed.js#1199
but it's actually breaks the last test for patchApply, so I'm doubting about my
understanding of locations within text. So, can you make it clear what is that
location in xIndex method?
By the way, there is a small bug in the doc example for xIndex:
e.g. 'The cat' vs 'The big cat', 1->1, 5->8
There was 4 chars inserted ("big "), so 5 should became 9.
Original issue reported on code.google.com by grigory.kalabin on 29 Apr 2014 at 3:05