1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-07-01 00:35:06 +02:00

Use utf8.RuneCountInString() rather than len() :(

Fixes #10. Thanks @curio77.
This commit is contained in:
Alec Thomas
2017-09-20 20:36:25 +10:00
parent 3f941ddff4
commit 36ead7258a

View File

@ -5,6 +5,7 @@ import (
"regexp" "regexp"
"strings" "strings"
"sync" "sync"
"unicode/utf8"
"github.com/dlclark/regexp2" "github.com/dlclark/regexp2"
) )
@ -221,7 +222,7 @@ func (r *RegexLexer) Tokenise(options *TokeniseOptions, text string, out func(*T
state.Rule = ruleIndex state.Rule = ruleIndex
state.Groups = groups state.Groups = groups
state.Pos += len(groups[0]) state.Pos += utf8.RuneCountInString(groups[0])
if rule.Mutator != nil { if rule.Mutator != nil {
if err := rule.Mutator.Mutate(state); err != nil { if err := rule.Mutator.Mutate(state); err != nil {
return err return err