Skip to content

Commit

Permalink
Merge pull request #15 from nyaxt/fixpanic
Browse files Browse the repository at this point in the history
Fix panic when counting remaining char
  • Loading branch information
lithammer authored Jun 19, 2018
2 parents 8261fa0 + c36657d commit b18e754
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
5 changes: 1 addition & 4 deletions fuzzy/fuzzy.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ Outer:
}

// Count up remaining char
for len(target) > 0 {
target = target[utf8.RuneLen(rune(target[0])):]
runeDiff++
}
runeDiff += utf8.RuneCountInString(target)

return runeDiff
}
Expand Down
1 change: 1 addition & 0 deletions fuzzy/fuzzy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var fuzzyTests = []struct {
{"ветер", "ёлочка", false, -1},
{"中国", "中华人民共和国", true, 5},
{"日本", "中华人民共和国", false, -1},
{"イ", "イカ", true, 1},
}

func TestFuzzyMatch(t *testing.T) {
Expand Down

0 comments on commit b18e754

Please sign in to comment.