What's wrong
DoesMatchGlob (TextFilter/TextFilter.cs ~344) picks the function that combines the optional tokens like this:
Func<...> optionalMatchFunc = textFilterMatchOptions is TextFilterMatchOptions.ByWordAny
? Enumerable.Any
: Enumerable.All;
That means ByWholeString also falls through to All. Under ByWholeString the text is a single token, so a filter with two or more optional alternatives matches only text that satisfies every alternative at once. For extension globs, no text can do that.
This contradicts the documented contract. GetHint(TextFilterType.Glob) says the "text must contain one of the optional tokens, all of the required tokens, and none of the excluded tokens". It also disagrees with ByWordAny on the same single-word text, which returns true.
Repro (reproduced)
TextFilter.IsMatch("photo.jpg", "*.jpg *.png", TextFilterType.Glob, TextFilterMatchOptions.ByWholeString); // False
TextFilter.IsMatch("photo.jpg", "*.jpg *.png", TextFilterType.Glob, TextFilterMatchOptions.ByWordAny); // True
TextFilter.Filter(new[]{"a.jpg","b.png","c.txt"}, "*.jpg *.png", TextFilterType.Glob, TextFilterMatchOptions.ByWholeString); // empty
// Expected: True, and [a.jpg, b.png]
Why it matters
ByWholeString is the natural mode for filtering file names and paths. When a user types two alternatives into a filter box, the list is emptied silently, with no error.
Suggested fix
Use All only for ByWordAll, and Any otherwise:
textFilterMatchOptions is TextFilterMatchOptions.ByWordAll ? Enumerable.All : Enumerable.Any
Acceptance: a test pins ByWholeString with multiple optional tokens so that one matching alternative is enough.
What's wrong
DoesMatchGlob(TextFilter/TextFilter.cs~344) picks the function that combines the optional tokens like this:That means ByWholeString also falls through to
All. Under ByWholeString the text is a single token, so a filter with two or more optional alternatives matches only text that satisfies every alternative at once. For extension globs, no text can do that.This contradicts the documented contract.
GetHint(TextFilterType.Glob)says the "text must contain one of the optional tokens, all of the required tokens, and none of the excluded tokens". It also disagrees with ByWordAny on the same single-word text, which returns true.Repro (reproduced)
Why it matters
ByWholeString is the natural mode for filtering file names and paths. When a user types two alternatives into a filter box, the list is emptied silently, with no error.
Suggested fix
Use
Allonly for ByWordAll, andAnyotherwise:Acceptance: a test pins ByWholeString with multiple optional tokens so that one matching alternative is enough.