fast_diff_match_patch icon indicating copy to clipboard operation
fast_diff_match_patch copied to clipboard

Strange diffs

Open Ymiros0 opened this issue 2 years ago • 1 comments

This diff tool seems to have some issues. I encountered this by chance, but output like ('-',0) appears, which doesn't make any sense. For example

old = 'e_"thati,"rgam i,"rgao i,"rgats""\ttj_n"l,"_e_rmem:o\ngoctep_"l,"_e_rmerg""\thwi:o\ner"n\ndg""\tlyrg""\n\t}\n}'
new = '\n\t\t3,\n\t\t\t5,\n\t\t\t5\n\t\t}\n\t},\n\tall = {\n\t\t1,\n\t\t2,\n\t\t3,\n\t\t4,\n\t\t5,\n\t\t6,\n\t\t7,\n\t\t8,\n\t\t9,\n\t\t10,\n\t\t11,\n\t\t12\n\t}\n}\n'
dif = diff(old,new)

returns

[('-', 96), ('+', 95), ('=', 4), ('-', 0), ('=', 1), ('+', 1)]

As soon as I change anything the -0 disappears and leaves me with a =5 though. Another thing I found is alternating + and - which also does not make sense:

old = 'log",\n\t\t"ot: "log",\n\t\t"error": "print",\n\t\t"debug": "log",\n\t\t"all_key_warning": "log"\n\t}\n}'
new = '12,\n\t\t\t3,\n\t\t\t5,\n\t\t\t5\n\t\t}\n\t},\n\tall = {\n\t\t1,\n\t\t2,\n\t\t3,\n\t\t4,\n\t\t5,\n\t\t6,\n\t\t7,\n\t\t8,\n\t\t9,\n\t\t10,\n\t\t11,\n\t\t12\n\t}\n}\n'
dif = diff(old,new)

returns

[('-', 18), ('+', 8), ('=', 4), ('+', 1), ('-', 16), ('+', 1), ('=', 4), ('+', 1), ('-', 42), ('+', 80), ('=', 5), ('+', 1)]

Whether these are issues with the base library or just this port I was unable to tell. At least the python port for the original google script didn't have these issues with these exact test strings.

Ymiros0 avatar Oct 30 '23 00:10 Ymiros0

I'm not actively maintaining the project but I'll leave the issue open in case anyone can find the problem.

JoshData avatar Nov 06 '23 20:11 JoshData