google-diff-match-patch cannot be applied if it has more than one patch operation on property
arbitertl opened this issue · 0 comments
arbitertl commented
JsonDiffPatch.Patch throws "Invalid textline" exception in case there are more than one operation in efficient string patch:
else if (patchArray.Count == 3) // Delete, Move or TextDiff
{
if (patchArray[2].Type != JTokenType.Integer)
throw new InvalidDataException("Invalid patch object");
int op = patchArray[2].Value<int>();
if (op == 0)
{
return null;
}
else if (op == 2)
{
var dmp = new diff_match_patch();
List<Patch> patches = dmp.patch_fromText(patchArray[0].ToObject<string>());
if (patches.Count != 1)
throw new InvalidDataException("Invalid textline"); //<======= THIS IS A VALID CASE!
string right = dmp.diff_text2(patches[0].diffs);
return right;
}
else
{
throw new InvalidDataException("Invalid patch object");
}
}