Skip to content

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

Description

@matt-edmondson

What's wrong

The fix for #106 turns a glob that won't parse (such as file[0-) into a match-anything glob (TextFilter/TextFilter.cs, ~lines 415-423). That works for plain and required (+) tokens: the token is effectively ignored while the user finishes typing.

For an excluded token (-, ! or ^ prefix, checked at ~line 337), match-anything means "exclude everything". So the list empties while the user is still typing -readme[a-z]. The #106 regression test (GlobWithAHalfTypedRangeDoesNotThrow) only covers unprefixed tokens.

Repro

TextFilter.Filter(["file1.txt", "file2.txt", "readme.md"], f) with the default Glob / ByWordAny options:

'-readme[a-'  -> []                                   <- expected all three items
'+file[0-'    -> [file1.txt, file2.txt, readme.md]
'file[0-'     -> [file1.txt, file2.txt, readme.md]

Reproduced against the current main build.

Why it matters

This is the type-ahead scenario #106 was fixed for. With an exclusion, every keystroke between [ and ] blanks the whole list, then it reappears when the range is closed. The flicker makes exclusion filters look broken.

Suggested fix

Have ResolveGlob return null (or a sentinel) for a token that won't parse, and skip such tokens in the optional, required and excluded checks alike. Alternatively, use a match-nothing fallback for excluded tokens.

Acceptance criteria

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions