my fork of dmp
Diffstat (limited to 'src/dmp.rs')
| -rw-r--r-- | src/dmp.rs | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -2350,12 +2350,12 @@ impl DiffMatchPatch { // of the previous patch. If there are patches expected at positions 10 and // 20, but the first patch was found at 12, delta is 2 and the second patch // has an effective expected position of 22. - let mut delta = 0; + let mut delta = 0_isize; let mut results = vec![false; patches.len()]; // patches.iter().enumerate().for_each(|(x, p)| { for (x, p) in patches.iter().enumerate() { - let expected_loc = p.start2 + delta; + let expected_loc = p.start2 + delta as usize; let txt_old = Self::diff_text_old(&p.diffs); let (start_loc, end_loc) = if txt_old.len() > self.match_max_bits() { // patch_splitMax will only provide an oversized pattern in the case of @@ -2385,7 +2385,8 @@ impl DiffMatchPatch { if let Some(sl) = start_loc { // Found a match. :) results[x] = true; - delta = sl - expected_loc; + println!("{sl} {expected_loc}"); + delta = (sl - expected_loc) as isize; let txt_new = if let Some(el) = end_loc { // safeMid(text, start_loc, end_loc + Match_MaxBits - start_loc); @@ -2442,7 +2443,7 @@ impl DiffMatchPatch { // No match found. :( results[x] = false; // Subtract the delta for this failed patch from subsequent patches. - delta -= p.length2 - p.length1; + delta -= (p.length2 - p.length1) as isize; } } |