Skip to content

Commit 1cf1560

Browse files
committed
chore: upgrade to github.com/dlclark/regexp2/v2
1 parent 2cbcf7b commit 1cf1560

9 files changed

Lines changed: 18 additions & 19 deletions

File tree

cmd/chroma/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/alecthomas/chroma/v2/cmd/chroma
22

3-
go 1.22
3+
go 1.26
44

55
toolchain go1.26.3
66

@@ -14,6 +14,6 @@ require (
1414
)
1515

1616
require (
17-
github.com/dlclark/regexp2 v1.12.0 // indirect
17+
github.com/dlclark/regexp2/v2 v2.0.2 // indirect
1818
golang.org/x/sys v0.29.0 // indirect
1919
)

cmd/chroma/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/alecthomas/kong v1.15.0 h1:BVJstKbpO73zKpmIu+m/aLRrNmWwxXPIGTNin9VmLV
44
github.com/alecthomas/kong v1.15.0/go.mod h1:wrlbXem1CWqUV5Vbmss5ISYhsVPkBb1Yo7YKJghju2I=
55
github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=
66
github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
7-
github.com/dlclark/regexp2 v1.12.0 h1:0j4c5qQmnC6XOWNjP3PIXURXN2gWx76rd3KvgdPkCz8=
8-
github.com/dlclark/regexp2 v1.12.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
7+
github.com/dlclark/regexp2/v2 v2.0.2 h1:2wqyuetE2L4JkwDaEBL255hSNFE/MNcss4sn0DReFc4=
8+
github.com/dlclark/regexp2/v2 v2.0.2/go.mod h1:Bz5TMy5d8fPK0ximH0Yi9KvsRHNnvXqUx9XG6a4wB+I=
99
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
1010
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
1111
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=

cmd/chromad/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/alecthomas/chroma/v2/cmd/chromad
22

3-
go 1.22
3+
go 1.26
44

55
toolchain go1.26.3
66

@@ -14,7 +14,7 @@ require (
1414
)
1515

1616
require (
17-
github.com/dlclark/regexp2 v1.12.0 // indirect
17+
github.com/dlclark/regexp2/v2 v2.0.2 // indirect
1818
github.com/felixge/httpsnoop v1.0.3 // indirect
1919
github.com/gorilla/securecookie v1.1.2 // indirect
2020
github.com/hashicorp/hcl v1.0.0 // indirect

cmd/chromad/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs
99
github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
1010
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1111
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
12-
github.com/dlclark/regexp2 v1.12.0 h1:0j4c5qQmnC6XOWNjP3PIXURXN2gWx76rd3KvgdPkCz8=
13-
github.com/dlclark/regexp2 v1.12.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
12+
github.com/dlclark/regexp2/v2 v2.0.2 h1:2wqyuetE2L4JkwDaEBL255hSNFE/MNcss4sn0DReFc4=
13+
github.com/dlclark/regexp2/v2 v2.0.2/go.mod h1:Bz5TMy5d8fPK0ximH0Yi9KvsRHNnvXqUx9XG6a4wB+I=
1414
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
1515
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
1616
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.26
55
require (
66
github.com/alecthomas/assert/v2 v2.11.0
77
github.com/alecthomas/repr v0.5.2
8-
github.com/dlclark/regexp2 v1.12.0
8+
github.com/dlclark/regexp2/v2 v2.0.2
99
)
1010

1111
require github.com/hexops/gotextdiff v1.0.3 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v
22
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
33
github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=
44
github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
5-
github.com/dlclark/regexp2 v1.12.0 h1:0j4c5qQmnC6XOWNjP3PIXURXN2gWx76rd3KvgdPkCz8=
6-
github.com/dlclark/regexp2 v1.12.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
5+
github.com/dlclark/regexp2/v2 v2.0.2 h1:2wqyuetE2L4JkwDaEBL255hSNFE/MNcss4sn0DReFc4=
6+
github.com/dlclark/regexp2/v2 v2.0.2/go.mod h1:Bz5TMy5d8fPK0ximH0Yi9KvsRHNnvXqUx9XG6a4wB+I=
77
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
88
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=

lexers/raku.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strings"
77
"unicode/utf8"
88

9-
"github.com/dlclark/regexp2"
9+
"github.com/dlclark/regexp2/v2"
1010

1111
. "github.com/alecthomas/chroma/v2" // nolint
1212
)
@@ -458,8 +458,7 @@ func rakuRules() Rules {
458458
var podRegex *regexp2.Regexp
459459
if tokenClass == rakuPod {
460460
podRegex = regexp2.MustCompile(
461-
state.NamedGroups[`ws`]+`=end`+`\s+`+regexp2.Escape(state.NamedGroups[`name`]),
462-
0,
461+
state.NamedGroups[`ws`] + `=end` + `\s+` + regexp2.Escape(state.NamedGroups[`name`]),
463462
)
464463
} else {
465464
closingChars = []rune(strings.Repeat(string(closingChar), nChars))
@@ -478,7 +477,7 @@ func rakuRules() Rules {
478477
match, err := podRegex.FindRunesMatchStartingAt(text, searchPos+nChars)
479478
if err == nil {
480479
closingChars = match.Runes()
481-
nextClosePos = match.Index
480+
nextClosePos = match.RuneIndex
482481
} else {
483482
nextClosePos = -1
484483
}

regexp.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"time"
1414
"unicode/utf8"
1515

16-
"github.com/dlclark/regexp2"
16+
"github.com/dlclark/regexp2/v2"
1717
)
1818

1919
// A Rule is the fundamental matching unit of the Regex lexer state machine.
@@ -368,7 +368,7 @@ func (r *RegexLexer) maybeCompile() (err error) {
368368
pattern = "(?" + rule.flags + ")" + pattern
369369
}
370370
pattern = `\G` + pattern
371-
rule.Regexp, err = regexp2.Compile(pattern, 0)
371+
rule.Regexp, err = regexp2.Compile(pattern)
372372
if err != nil {
373373
return fmt.Errorf("failed to compile rule %s.%d: %s", state, i, err)
374374
}
@@ -500,7 +500,7 @@ func (r *RegexLexer) MustRules() Rules {
500500
func matchRules(text []rune, pos int, rules []*CompiledRule) (int, *CompiledRule, []string, map[string]string) {
501501
for i, rule := range rules {
502502
match, err := rule.Regexp.FindRunesMatchStartingAt(text, pos)
503-
if match != nil && err == nil && match.Index == pos {
503+
if match != nil && err == nil && match.RuneIndex == pos {
504504
groups := []string{}
505505
namedGroups := make(map[string]string)
506506
for _, g := range match.Groups() {

serialise.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"regexp"
1414
"strings"
1515

16-
"github.com/dlclark/regexp2"
16+
"github.com/dlclark/regexp2/v2"
1717
)
1818

1919
// Serialisation of Chroma rules to XML. The format is:

0 commit comments

Comments
 (0)