Skip to content

Commit 5b055fa

Browse files
committed
fix
1 parent 307d5b2 commit 5b055fa

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

diffmatchpatch/diff.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,8 @@ func commonSuffixLength(text1, text2 []rune) int {
500500
// DiffCommonOverlap determines if the suffix of one string is the prefix of another.
501501
func (dmp *DiffMatchPatch) DiffCommonOverlap(text1 string, text2 string) int {
502502
// Cache the text lengths to prevent multiple calls.
503-
text1Length := len(text1)
504-
text2Length := len(text2)
503+
text1Length := len([]rune(text1))
504+
text2Length := len([]rune(text2))
505505
// Eliminate the null case.
506506
if text1Length == 0 || text2Length == 0 {
507507
return 0

diffmatchpatch/diff_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,18 @@ func TestDiffCleanupSemantic(t *testing.T) {
845845
{DiffInsert, "a new hope"},
846846
},
847847
},
848+
{
849+
"panic",
850+
[]Diff{
851+
{DiffInsert, "킬러 인 "},
852+
{DiffEqual, "리커버리"},
853+
{DiffDelete, " 보이즈"},
854+
},
855+
[]Diff{
856+
{DiffDelete, "리커버리 보이즈"},
857+
{DiffInsert, "킬러 인 리커버리"},
858+
},
859+
},
848860
} {
849861
actual := dmp.DiffCleanupSemantic(tc.Diffs)
850862
assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %s", i, tc.Name))

0 commit comments

Comments
 (0)