Skip to content

Match a mixed-case glob range the same under both case sensitivities [patch] - #168

Open
matt-edmondson wants to merge 4 commits into
mainfrom
fix/mixed-case-glob-range
Open

matt-edmondson wants to merge 4 commits into
mainfrom
fix/mixed-case-glob-range

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #167

What changed

  • IsNativeGlobRange leaves a lone range to DotNet.Glob only when both endpoints are lower case, both are upper case, or both are ASCII digits, as the issue suggests. A mixed-case range such as A-z or Z-a now goes through ToGlobCharacterList, which already handles case folding correctly.
  • Deviation from the suggested fix: a lone reversed letter range such as a-Z gives ToGlobCharacterList no members. That returns null, so the token was ignored and matched everything, not the expected false. The existing ExpandGlobClassesRejectsClassesThatCannotBeListed test pins null for reversed non-letter ranges like [#-!], so I left that path alone. Instead, IsReversedLetterRange writes a reversed letter range as [9-0] (or [!9-0]). DotNet.Glob reads that as empty, and case folding can't change it. That keeps the result CaseSensitive already gave: [a-Z] matches nothing and [!a-Z] matches any character.

Tests

  • GlobRangeWithMixedCaseEndpointsMatchesTheSameUnderBothSensitivities covers every row of the issue's table, including the negated and reversed rows, plus controls. Each row is checked under both sensitivities.
  • GlobRangeWithSameCaseEndpointsStillFoldsUnderCaseInsensitive: [a-z] still matches M only under CaseInsensitive.
  • CaseInsensitiveGlobClassMatchesEverythingCaseSensitiveDoes is a property-style check over printable ASCII: every CaseSensitive match of a non-negated class is also a CaseInsensitive match.
  • With the fix reverted, 8 tests fail. With it, the full suite passes on net10.0 (213/213).

This edits code near open PRs #162–#166, so a textual conflict with one of them is possible.


Generated by Claude Code

…[patch]

DotNet.Glob lowercases a range's endpoints under CaseInsensitive, so a lone
native range whose endpoints differ in case changed meaning: "A-z" became
"a-z" and stopped matching "_" and "[", "Z-a" became the empty "z-a", and
the reversed "a-Z" became "a-z". Only same-case letter and digit ranges are
now left to DotNet.Glob; a mixed-case range is listed explicitly, and a
reversed letter range is written as the empty "[9-0]", which matches nothing
under either sensitivity, as it already did under CaseSensitive.

Fixes #167

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW6QSBbC4yjv9GxYCN1
Comment thread TextFilter.Test/TextFilterTests.cs Fixed
claude and others added 2 commits October 30, 2026 23:35
Replaces the nested ternary in ExpandGlobClasses with a helper, which
SonarCloud flagged (S3358, and S3776 cognitive complexity). The
case-insensitivity property test now filters its patterns with Where and
drops the negated entries it never asserted on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW6QSBbC4yjv9GxYCN1
Resolve the IsNativeGlobRange conflict with #164: a lone range stays
native only when its endpoints share a case or are both digits, and it
does not span a path separator.

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

Copy link
Copy Markdown

…ange

# Conflicts:
#	TextFilter/TextFilter.cs
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.

Case-insensitive glob matches less than case-sensitive for mixed-case ranges: [A-z] stops matching "_", [Z-a] stops matching "a"

2 participants