Skip to content

Since the trailing-dash fix (6937eb9), [a-z-] no longer matches "q", file[0-9a-] no longer matches "file5", and []a-] matches nothing #153

Closed

Description

@matt-edmondson

What's wrong

MoveTrailingClassDashes (TextFilter/TextFilter.cs, ~L474-518, added in 6937eb9 for #130) moves the dash to the front of every class that ends in -. It does this even for classes DotNet.Glob already parsed correctly, and a leading - pushes DotNet.Glob into character-list mode. There, - is a member and ranges aren't read (see #152).

Pattern Before 6937eb9 After the rewrite
[a-z-] letter range: q matches [-a-z] = list of -, a, z: q doesn't match
file[0-9a-] number range: file5 matches file[-0-9a] = list of -, 0, 9, a: file5 doesn't match
[]a-] list: a, -, ] all match [-]a] = class [-] followed by the literal a]: none of them match
[!]a-] negated list broken the same way

Repro (verified with tests through TextFilter.IsMatch, Glob, ByWholeString)

failed TrailingDashRange          Assert.IsTrue(IsMatch("q", "[a-z-]"))
failed TrailingDashDigits         Assert.IsTrue(IsMatch("file5", "file[0-9a-]"))
failed LeadingBracketTrailingDash Assert.IsTrue(IsMatch("a","[]a-]") && IsMatch("-","[]a-]") && IsMatch("]","[]a-]"))

The existing test (TextFilter.Test/TextFilterTests.cs, ~L970-971) only checks the rewritten text ("[0-9a-]" -> "[-0-9a]", "[]-]" -> "[-]]"), not what the result matches, so the regression got through.

Why it matters

Patterns that worked before the #130 fix now silently hide matching items. []a-] turns into a pattern that matches nothing at all.

Suggested fix / acceptance criteria

Activity

  1. added
    bug
    on Oct 20, 2026
  2. matt-edmondson commented on Oct 23, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    Notes: This is a regression: patterns that worked before now silently hide matching items, and []a-] matches nothing at all. If #152's expansion approach takes longer, a quick interim fix is to rewrite only the forms that fail to parse and never move the dash in front of a leading ]. Either way, replace the text-only rewrite assertions with match assertions.


    Generated by Claude Code

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

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions