Skip to content

Glob ** joined to other characters (**foo, a**b) matches almost nothing, where *foo / a*b match as expected #135

Description

@matt-edmondson

What's wrong

ResolveGlob (TextFilter/TextFilter.cs:~412-444) passes a ** through to DotNet.Glob unchanged. DotNet.Glob only treats ** as a wildcard when it is a whole path segment. When it touches other characters it means "zero directories", so it matches nothing. In a text filter, where a person types a pattern into a box and expects * semantics, a doubled star therefore empties the results instead of behaving like *.

Reproduction (HEAD d19c5b4)

Call Result Same pattern with one *
IsMatch("xfoo", "**foo", Glob) false (only matches foo exactly) *foo → true
IsMatch("axb", "a**b", Glob) false a*b → true
IsMatch("ab", "a**b", Glob) false a*b → true

Calling Glob.Parse directly gives the same results, so this isn't a regression from the #114 masking. The root cause is the same one behind #126, but the fix #126 proposes (rewriting ** followed by a separator) wouldn't cover it: here ** is next to letters, not separators.

Why it matters

Typing an extra * is an easy slip, and some people type ** on purpose, expecting "anything". Either way the item list silently goes empty, and nothing says the pattern is to blame.

Suggested fix

In ResolveGlob, before masking, collapse any run of two or more * that is not a whole path segment down to a single *. A regex on runs of * with separator/boundary lookarounds would do it. Leave whole-segment ** for the #126 fix. Doing both in one PR keeps the ** rules in one place.

Acceptance criteria

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions