Skip to content

Commit

Permalink
Merge pull request #5 from noborus/fix-panic
Browse files Browse the repository at this point in the history
Fixed wrong place for slice check
  • Loading branch information
noborus authored Jul 6, 2023
2 parents 68c01a3 + 892cc3d commit 46b2fd6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions guesswidth.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ func lookupBlanks(line string) []int {
func countBlanks(blanks []int, line string) []int {
n := 0
for _, r := range line {
if n >= len(blanks) {
break
}
if r == ' ' && blanks[n] > 0 {
blanks[n] += 1
}
Expand All @@ -269,9 +272,6 @@ func countBlanks(blanks []int, line string) []int {
if runewidth.RuneWidth(r) == 2 {
n += 1
}
if n >= len(blanks) {
break
}
}
return blanks
}
Expand Down

0 comments on commit 46b2fd6

Please sign in to comment.