Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pakohan committed Dec 10, 2019
1 parent 307d5b2 commit 5b055fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions diffmatchpatch/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ func commonSuffixLength(text1, text2 []rune) int {
// DiffCommonOverlap determines if the suffix of one string is the prefix of another.
func (dmp *DiffMatchPatch) DiffCommonOverlap(text1 string, text2 string) int {
// Cache the text lengths to prevent multiple calls.
text1Length := len(text1)
text2Length := len(text2)
text1Length := len([]rune(text1))
text2Length := len([]rune(text2))
// Eliminate the null case.
if text1Length == 0 || text2Length == 0 {
return 0
Expand Down
12 changes: 12 additions & 0 deletions diffmatchpatch/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,18 @@ func TestDiffCleanupSemantic(t *testing.T) {
{DiffInsert, "a new hope"},
},
},
{
"panic",
[]Diff{
{DiffInsert, "킬러 인 "},
{DiffEqual, "리커버리"},
{DiffDelete, " 보이즈"},
},
[]Diff{
{DiffDelete, "리커버리 보이즈"},
{DiffInsert, "킬러 인 리커버리"},
},
},
} {
actual := dmp.DiffCleanupSemantic(tc.Diffs)
assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %s", i, tc.Name))
Expand Down

0 comments on commit 5b055fa

Please sign in to comment.