Skip to content

Commit 9a8a647

Browse files
committed
Report file pattern errors when a lexer is initialised.
See #555
1 parent 07a127d commit 9a8a647

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: regexp.go

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package chroma
33
import (
44
"fmt"
55
"os"
6+
"path/filepath"
67
"regexp"
78
"sort"
89
"strings"
@@ -238,6 +239,12 @@ func NewLazyLexer(config *Config, rulesFunc func() Rules) (*RegexLexer, error) {
238239
if config == nil {
239240
config = &Config{}
240241
}
242+
for _, glob := range append(config.Filenames, config.AliasFilenames...) {
243+
_, err := filepath.Match(glob, "")
244+
if err != nil {
245+
return nil, fmt.Errorf("%s: %q is not a valid glob: %w", config.Name, glob, err)
246+
}
247+
}
241248
return &RegexLexer{
242249
config: config,
243250
compilerFunc: rulesFunc,

0 commit comments

Comments
 (0)