Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

diff_xIndex TypeError exception handled.

  • Loading branch information...
commit 5b138fd4bf33e6fd2284327202e2452e3e2bea50 1 parent 7cc298e
@suruja authored
Showing with 9 additions and 1 deletion.
  1. +1 −1  lib/diff_match_patch.rb
  2. +8 −0 test/test_diff_match_patch.rb
View
2  lib/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.
View
8 test/test_diff_match_patch.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.