You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Glob class with a trailing dash like file[a-] is treated as unparseable: as a filter it shows every item, as an exclusion it hides nothing #130
file[a-] is a complete, valid glob. In glob syntax a - right before ] is a literal dash, so the class matches a or -. DotNet.Glob's tokeniser still throws IndexOutOfRangeException on it. ResolveGlob (TextFilter.cs:417-443) catches that and caches the token as unparseable (null). By the rule documented at lines 305-309, an unparseable token matches everything as a plain or required token and excludes nothing as an excluded token.
varitems=new[]{"filea","file-","fileZ","report"};TextFilter.Filter(items,"file[a-]");// -> filea, file-, fileZ, report (expected: filea, file-)TextFilter.Filter(items,"-file[a-]");// -> filea, file-, fileZ, report (expected: fileZ, report)DotNet.Globbing.Glob.Parse("file[a-]");// throws IndexOutOfRangeExceptionDotNet.Globbing.Glob.Parse("file[-a]").IsMatch("file-");// true: the leading-dash form works
The results above were observed by running against HEAD 769c9b1.
Why it matters
The "ignore unparseable tokens" fallback from #106/#110 was meant for half-typed ranges such as file[0-. It also swallows this finished, legal pattern, and nothing tells the user. The results are the opposite of what was asked for:
The include filter shows report, which doesn't even start with file.
The exclusion removes nothing.
Suggested fix
In ResolveGlob, before calling Glob.Parse, rewrite each character class so that a - immediately before the closing ] moves to the front of the class, after any !:
[a-] becomes [-a]
[!a-] becomes [!-a]
DotNet.Glob parses that form correctly. Keep the existing catch for genuinely half-typed input such as file[0-.
Acceptance criteria: tests show that file[a-] includes filea and file- only, -file[a-] excludes exactly those, and file[0- still behaves as it does today.
Rationale: This is an edge-case pattern ([a-]) with an easy workaround ([-a]). The results are wrong and nothing warns the user, but few people will hit it. The fix is a small rewrite applied before Glob.Parse.
Activity
matt-edmondson commentedon Sep 29, 2026
Triage
ResolveGlob, which works around a tokeniser limitation in DotNet.Glob**/patterns match nothing since the #114 separator fix:src/**/*.csand**/*.csfilter out every path #126 (**/glob regression) is in the same glob-resolution code and is the more impactful of the two, so fix it first and batch this one with itRationale: This is an edge-case pattern (
[a-]) with an easy workaround ([-a]). The results are wrong and nothing warns the user, but few people will hit it. The fix is a small rewrite applied beforeGlob.Parse.Generated by Claude Code
Match a trailing dash in a glob class literally [patch]