Skip to content

Fold an inline (?i) culture-invariantly too [patch] - #121

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/textfilter-120-inline-ignorecase-culture
Sep 28, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/textfilter-120-inline-ignorecase-culture

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #120

Problem

DoesMatchRegex set RegexOptions.CultureInvariant only for CaseInsensitive. A CaseSensitive filter can still request a fold itself with an inline (?i), and that fold then used the thread's current culture. If (?i)img was compiled under tr-TR first, it stopped matching IMG_1234.JPG, and because the regex cache is keyed by pattern and sensitivity only, every later caller got the same answer.

Change

  • TextFilter/TextFilter.cs: every compiled filter now uses Compiled | CultureInvariant, and IgnoreCase is added only for CaseInsensitive.
  • TextFilter.Test/TextFilterTests.cs: added AnInlineIgnoreCaseFoldsTheSameWhateverCultureCompiledIt. It compiles (?i)img under tr-TR first, then expects a match under both tr-TR and en-US.

Verification

  • With the fix reverted, the new test fails at Assert.IsTrue(underTurkish).
  • With the fix, the full suite passes: 116 of 116.

🤖 Generated with Claude Code

https://claude.ai/code/session_01P1dENrzXtWG4vP7thSjyof


Generated by Claude Code

CultureInvariant was only set for CaseInsensitive, so a CaseSensitive
pattern that asked for its own fold with (?i) still folded by the
current culture. Compiled under tr-TR, "(?i)img" stopped matching
"IMG_1234.JPG", and the regex cache kept that compile for every later
caller. Set CultureInvariant on every compiled filter.

Fixes #120

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

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

2 participants