Permalink
Browse files

diff_xIndex TypeError exception handled.

  • Loading branch information...
1 parent 7cc298e commit 5b138fd4bf33e6fd2284327202e2452e3e2bea50 @suruja committed Apr 19, 2012
Showing with 9 additions and 1 deletion.
  1. +1 −1 lib/diff_match_patch.rb
  2. +8 −0 test/test_diff_match_patch.rb
@@ -914,7 +914,7 @@ def diff_xIndex(diffs, loc)
last_chars2 = chars2
false
end
- end
+ end || 0
if diffs.length != x && diffs[x][0] == :delete
# The location was deleted.
@@ -1204,5 +1204,13 @@ def test_patch_apply
patches = @dmp.patch_make('y', 'y123')
results = @dmp.patch_apply(patches, 'x')
assert_equal(['x123', [true]], results)
+
+ # Original text edited after the patches creation.
+ text = "Le ciel est bleu et le soleil brille."
+ patches = @dmp.patch_make(text, "Il pleut sur la ville et le soleil ne brille pas.")
+ text = "La lune est blonde et le soleil brille."
+ assert_nothing_raised do
+ @dmp.patch_apply(patches, text)
+ end
end
end

0 comments on commit 5b138fd

Please sign in to comment.