Skip to content

Stop a half-typed excluded glob token hiding every item - #111

Merged
matt-edmondson merged 2 commits into
mainfrom
claude/textfilter-110-excluded-halftyped-glob
Sep 26, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
claude/textfilter-110-excluded-halftyped-glob

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #110

Problem

The fix for #106 turned a glob token that won't parse (such as file[0-) into a match-anything glob. For plain and + tokens, that makes the token neutral. For an excluded token (-, ! or ^), "match anything" meant "exclude everything". So Filter(["file1.txt", "file2.txt", "readme.md"], "-readme[a-") returned [] on every keystroke until the range was closed.

Fix

  • ResolveGlob now returns null for a token that won't parse. It caches that null so the parse is still not retried on every keystroke. GlobCache is now ConcurrentDictionary<string, Glob?>.
  • The excluded-token check in DoesMatchGlob skips a null glob, so the token excludes nothing.
  • The public AnyTokenMatchesGlobFilter and AllTokensMatchGlobFilter treat null as matching anything, so optional and required tokens behave as before.
  • The unused GlobMatchAnything helper is removed, and the DoesMatchGlob remarks describe the new rule.

Tests

With the fix reverted, those 6 cases fail. With it, the full suite passes (101/101, dotnet test -c Release). The library also builds cleanly in Release for all of its target frameworks.

This PR is independent of #109; both branch from main. They touch different methods in TextFilter.cs.

🤖 Generated with Claude Code

https://claude.ai/code/session_012Hhb8knddbu4LRSs2uu9jR


Generated by Claude Code

claude and others added 2 commits September 26, 2026 05:29
A glob token that cannot be parsed (such as "file[0-") became a
match-anything glob. That ignores plain and required tokens, but for an
excluded token ("-readme[a-") it excluded everything, so the list
emptied while the user typed a range. ResolveGlob now caches an
unparseable token as null. Excluded tokens skip it; the other checks
still treat it as matching anything.

Fixes #110

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Hhb8knddbu4LRSs2uu9jR
Resolve the conflict in TextFilterTests.cs by keeping both the excluded
half-typed glob tests from this branch and the ByWordAll blank-text tests
from #109.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CZB6C9rAp2hA5WQDcw2NDp
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 10c84aa into main Sep 26, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the claude/textfilter-110-excluded-halftyped-glob branch September 26, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A half-typed range in an excluded glob token ("-readme[a-") hides every item

2 participants