Skip to content

Commit

Permalink
resolve annoying rune bug
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed May 29, 2023
1 parent 0830b4b commit 52fd9be
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions index.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,14 @@ func IndexAllIgnoreCase(haystack string, needle string, limit int) [][]int {
}

// Cut off the number at the end to the number we need which is the length of the needle runes
var toMatch []rune
if match[0]+e > len(haystack) {
toMatch = []rune(haystack[match[0] : len(haystack)-1])[:len(needleRune)]
} else {
toMatch = []rune(haystack[match[0] : match[0]+e])[:len(needleRune)]
toMatchRune := []rune(haystack[match[0] : match[0]+e])
toMatchEnd := len(needleRune)
if len(toMatchRune) < len(needleRune) {
toMatchEnd = len(toMatchRune)
}

toMatch := toMatchRune[:toMatchEnd]

// old logic here
//toMatch = []rune(haystack[match[0] : match[0]+e])[:len(needleRune)]

Expand Down

0 comments on commit 52fd9be

Please sign in to comment.