Skip to content

Commit 7fffafa

Browse files
committed
fix : fix silly runtime error
1 parent 7751a1c commit 7fffafa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

javascript/diff_match_patch_uncompressed.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,8 +1774,10 @@ diff_match_patch.prototype.patch_addContext_ = function(patch, text) {
17741774
// Add one chunk for good luck.
17751775
padding += this.Patch_Margin;
17761776

1777+
1778+
17771779
// Add the prefix.
1778-
var prefix = this.isLowSurrogate(prefix[0]) // Avoid splitting on non-character boundaries
1780+
var prefix = this.isLowSurrogate(text[patch.start2 - padding]) // Avoid splitting on non-character boundaries
17791781
? text.substring(patch.start2 - padding - 1 , patch.start2)
17801782
: text.substring(patch.start2 - padding , patch.start2);
17811783

@@ -1784,7 +1786,7 @@ diff_match_patch.prototype.patch_addContext_ = function(patch, text) {
17841786
}
17851787

17861788
// Add the suffix.
1787-
var suffix = this.isHighSurrogate(suffix[suffix.length-1]) // Avoid splitting on non-character boundaries
1789+
var suffix = this.isHighSurrogate(text[patch.start2 + patch.length1 + padding]) // Avoid splitting on non-character boundaries
17881790
? text.substring(patch.start2 + patch.length1, patch.start2 + patch.length1 + padding + 1)
17891791
: text.substring(patch.start2 + patch.length1, patch.start2 + patch.length1 + padding);
17901792

0 commit comments

Comments
 (0)