1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-19 21:10:15 +02:00

regexp2 uses number of group as its name so name check isn't needed

This commit is contained in:
Siavash Askari Nasr 2021-05-08 11:45:10 +04:30 committed by Alec Thomas
parent 1b7d2dd620
commit 2e23e7f215

View File

@ -504,11 +504,9 @@ func matchRules(text []rune, pos int, rules []*CompiledRule) (int, *CompiledRule
match, err := rule.Regexp.FindRunesMatchStartingAt(text, pos)
if match != nil && err == nil && match.Index == pos {
groups := []string{}
namedGroups := map[string]string{}
namedGroups := make(map[string]string)
for _, g := range match.Groups() {
if g.Name != `` {
namedGroups[g.Name] = g.String()
}
namedGroups[g.Name] = g.String()
groups = append(groups, g.String())
}
return i, rule, groups, namedGroups