Skip to content

matcher: Implement prefer_basename mode#101

Open
archseer wants to merge 1 commit into
masterfrom
prefer-basename
Open

matcher: Implement prefer_basename mode#101
archseer wants to merge 1 commit into
masterfrom
prefer-basename

Conversation

@archseer

Copy link
Copy Markdown
Member

Match fzf's --scheme=path: matches in the basename boost the candidate score. I've been bothered by this for a while on larger repositories. Slight performance hit for searching paths if enabled, but it only runs scoring for candidates that match in the first place.

Fixes #93

@archseer archseer requested a review from pascalkuthe June 24, 2026 05:43
Comment thread matcher/src/lib.rs
let score = self.fuzzy_matcher_impl_raw::<INDICES>(haystack_, needle_, indices)?;
// Reward a match that also lands in the basename so a file whose name
// matches outranks siblings that only match a shared parent directory.
// The bonus is the matcher's own score for the needle against that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats a pretty high bonus...

Mahbe thats ok but it seems quite high. Is that also waht fzf does?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair, fzf only uses this to resolve tiebreaks (it sets --tiebreak=pathname,length). I think the better solution is to add BONUS_BOUNDARY to the score. Enough to resolve the tie break, but not enough to prefer the basename match in the cases where there's better scoring matches available.

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.

Weird behavior: with more letters, desired match drops way down in score

2 participants