Reputation: 339
I am writing the text change tracking add-in and my code is:
mDiffMatchPatch = new diff_match_patch()
List<Diff> diffList = mDiffMatchPatch.diff_main(OriginalText, ModifiedText);
mDiffMatchPatch.diff_cleanupSemantic(diffList);
Where Diff is an object with two properties, 'text' and 'operation'
My original text is :
When I just insert the word 'ice' after 'installer' is shows up as it should:
But when I highlight 'installer' and type 'ice' on top of it (replacing 'installer' by 'ice' in one operation), it shows incorrectly.
That is, it takes the first letter of original 'installer' and separates 'i' from 'ce' in 'ice'.
I checked and re-rechecked and my text color rendering is correct. It is the diff_match_match breaks the 'i' from 'ice' in order to match it with the 'i' of 'installer'.
Is there any remedy for this? If not, is there alternative libraries in C# for diff_match_patch?
M
Upvotes: 0
Views: 581
Reputation: 339
I resolved it by following the guidance on project github page. That is, using the word-based diff function of the diff_match_patch object. You create it by copying line-based function and modifying it per article.
Upvotes: 0