Stop regex ByWordAll matching blank text - #109
Merged
Merged
Conversation
ExtractTextTokens returns no words for "" or " ", and Enumerable.All over an empty set is true, so the regex ByWordAll path reported blank text as matching every pattern while the glob path said no. The regex path now returns false when the text has no words. Fixes #107 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QPAgvLThqmty1U7AaebQMQ
…mpty-text-107 # Conflicts: # TextFilter.Test/TextFilterTests.cs
|
matt-edmondson
added a commit
that referenced
this pull request
Sep 26, 2026
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #107
What was wrong
ExtractTextTokensreturns an empty set for""or" "under the word match options. The regexByWordAllpath then ranEnumerable.Allover that set, andAllon an empty sequence istrue. As a result, blank text matched every regex pattern, so blank entries stayed visible in a list whatever the user typed. The glob path returnsfalsefor the same input.Change
DoesMatchRegexnow returnsfalsewhen the text has no words, before it picksAnyorAll. This is the option the issue and the triage both recommend, and it matches the glob path.ByWordAnyalready returnedfalsein this case, andByWholeStringnever produces an empty set, so neither changes.Tests
ByWordAllDoesNotMatchTextWithNoWordsrunsIsMatchandFilterover""and" "for both filter types, which ties the two paths together.RegexByWordAllFilterDropsBlankEntriescovers theFilter(["", "hello"], "zzz", ...)case from the issue. It also checks that a matching word is still kept.With the
TextFilter.cschange reverted, the 3 regex cases fail. The glob cases pass either way, which is expected since they guard against regressions. With the fix, the full suite passes: 94 of 94 (dotnet test TextFilter.Test -c Release).This PR is independent of #108 (#106). Both change
TextFilter.cs, in separate methods.🤖 Generated with Claude Code
https://claude.ai/code/session_01QPAgvLThqmty1U7AaebQMQ
Generated by Claude Code