Skip to content

Fuzzy filter treats inner whitespace as a literal character: "open file" can't find OpenFile.cs, and a double space or tab hides everything #142

Open

Description

@matt-edmondson

What's wrong

The fuzzy path passes the filter to Fuzzy.Contains after trimming only the ends (TextFilter/TextFilter.cs:251: Fuzzy.Contains(text.AsSpan(), filter.AsSpan().Trim(), out score)). Whitespace inside the query is a character the text must contain, unlike Glob and Regex, where whitespace separates tokens.

Repro (main @ 6ce4850)

string[] items = { "OpenFile.cs", "open_file.cs", "SaveFile.cs", "open file dialog" };
TextFilter.Filter(items, "open file",  TextFilterType.Fuzzy);   // [open file dialog]
TextFilter.Filter(items, "open  file", TextFilterType.Fuzzy);   // []   (two spaces)
TextFilter.IsMatch("OpenFile",     "open file",  TextFilterType.Fuzzy);  // false
TextFilter.IsMatch("open_file.cs", "open file",  TextFilterType.Fuzzy);  // false
TextFilter.IsMatch("OpenFile",     "openfile",   TextFilterType.Fuzzy);  // true
TextFilter.IsMatch("open file",    "open\tfile", TextFilterType.Fuzzy);  // false

Expected: a word break in a fuzzy query still finds OpenFile.cs and open_file.cs (as openfile already does), and an extra space or a tab doesn't empty the list.

Why it matters

#115 trimmed leading/trailing padding on the grounds that padding shouldn't become a space the text must contain; inner spaces have the same problem. A natural two-word query, or an accidental double space, silently hides real matches, and fuzzy behaves differently from the other two filter types.

Suggested fix

Either:

  • (a) Strip all whitespace from the fuzzy filter before calling Fuzzy.Contains (smallest change), or
  • (b) Split on whitespace, require every piece to fuzzy-match, and sum the scores. This would also give TextFilterMatchOptions a meaning for fuzzy, which it currently ignores.

Acceptance: the repro's "open file", "open file" and "open\tfile" queries match OpenFile.cs, open_file.cs and open file dialog, and not SaveFile.cs.

Activity

  1. matt-edmondson commented on Oct 6, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    Recommended next step: Option (a), stripping all whitespace, is the smallest fix. Option (b), splitting into tokens that must all match, is more consistent with the other filter types and gives TextFilterMatchOptions a meaning under fuzzy. That makes (b) the better choice if the API change is acceptable.


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions