ngoch / google-diff-match-patch

Automatically exported from code.google.com/p/google-diff-match-patch
Apache License 2.0
0 stars 0 forks source link

JS library gives wrong result. #110

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

var context = "It's easy as pie to use Mathjax. You just need to study and 
remember how to use $$ and $$$. As you can see, it's not that hard. So, let's 
try something a bit more complicated.\nHere was a line break with two spaces. 
Not that hard, right, grandpa?";
var anchorText = "just need to study and remember how to use $$ and";
var dmp = new diff_match_patch();
dmp.Match_MaxBits = 100;
var offset = dmp.match_main(context, anchorText, 60);
// offset = 69
// meaning: the match starts with "how to use $$ and $$$. As you can see,"

What is the expected output? What do you see instead?

I think offset should be 37, since that'll result in a perfect match. I also 
can't figure out a way to change Distance or Threshold parameters to cause that 
to happen. The only thing that works is changing the guess parameter ("60") to 
be smaller / closer to "37", but I unfortunately don't have that information 
for a generic case.

What version of the product are you using? On what operating system?
JavaScript; latest version

Please provide any additional information below.

Original issue reported on code.google.com by alexei.a...@gmail.com on 19 Jul 2015 at 8:35