Skip to content

Word-start matches after /, \, -, . or a tab get no separator bonus, so "domain.cs" outranks "src/main.cs" for "main" #92

Closed

Description

@matt-edmondson

What's wrong

Fuzzy.cs:280 only treats _ and a space as separators:

prevSeparator = strChar is '_' or ' ';

So a match that starts a path segment, a kebab-case word or a dotted name gets no matchAfterSeparatorBonus (+10). It scores the same as a match buried in the middle of a word. File paths and command names are what fuzzy finders mostly rank, including TextFilter's Fuzzy filter and Rank, so this is where the ranking goes wrong. Tab is also excluded, even though TextFilter now treats all whitespace as a word separator (TextFilter #112).

The XML doc on matchAfterSeparatorBonus, CLAUDE.md and the README all describe the current _/space behaviour. So this is an enhancement request rather than a bug.

Repro

int S(string s, string p) { Fuzzy.Contains(s, p, out int sc); return sc; }

S("src/main.cs", "main")  //  8
S("domain.cs",   "main")  // 10  <- mid-word match outranks the path-segment match
S("src_main.cs", "main")  // 18
S("src-main.cs", "main")  //  8  (same for "src.main.cs", "src\\main.cs", "src\tmain.cs")
S("get-list",    "list")  // 11
S("getlist",     "list")  // 12  <- outranks the hyphenated word
S("foo-bar", "fb") == S("fxxxbxx", "fb")  // both 5, while "foo_bar" scores 15

Suggested change

Widen the separator test to whitespace plus the common identifier and path separators, for example:

prevSeparator = char.IsWhiteSpace(strChar) || strChar is '_' or '-' or '.' or '/' or '\\';

A small static set would also work. Then update the matchAfterSeparatorBonus XML doc, the README scoring table and CLAUDE.md.

Acceptance criteria

  • Score("src/main.cs","main") > Score("domain.cs","main")
  • Score("src-main.cs","main") == Score("src_main.cs","main")
  • Score("get-list","list") > Score("getlist","list")
  • A tab earns the bonus the same way a space does.
  • The existing scoring tests still pass, or are updated only where they pinned the old separator set.

Activity

  1. matt-edmondson commented on Sep 27, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    • Category: Improvement
    • Priority: Medium. It degrades ranking quality for file paths and kebab/dotted names, which is the library's main use case, and TextFilter's Fuzzy filter and Rank inherit it. It matches the documented behaviour, so it is not a bug.
    • Area / suggested owner: Fuzzy.cs:280 separator test, plus the XML doc, README scoring table and CLAUDE.md
    • Duplicates / in progress: None found. Open PR Match Greek final sigma and the micro sign ignoring case [patch] #93 (Greek final sigma / micro sign case folding) is in the same file but unrelated.
    • Notes: Changing scores is observable to consumers who sort by score. Consider a minor version bump rather than a patch.

    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

enhancementNew feature or requestreadyFully specified; implement as written

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions