Skip to content

fuzzy_nucleo: Add a tail proximity bonus to fix the double hits not sorted higher bonus.#59224

Open
feitreim wants to merge 4 commits into
zed-industries:mainfrom
feitreim:feat-tail-proximity-bonus
Open

fuzzy_nucleo: Add a tail proximity bonus to fix the double hits not sorted higher bonus.#59224
feitreim wants to merge 4 commits into
zed-industries:mainfrom
feitreim:feat-tail-proximity-bonus

Conversation

@feitreim

@feitreim feitreim commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Objective

Fixes #55195

The issue is that if a path contains some part of the query multiple times, like x/x.py it may not outrank results like y/x.py (for the query x), despite the fact that it should.

Solution

I added a very small bonus that rewards the proximity of the matches to the tail-end of the path, this is easy because nucleo naturally favors the tail, so the tail most match for a given query atom will be the one that is found. This bonus does need to be small, though not too small, in order to not disrupt any other scoring orders.

The main benefit of this over a different approach like counting occurrences of an atom is speed, this approach is constant time and just overall very low overhead, but performance would be much more of a concern with other approaches.

Testing

All the file finder tests still pass.

Directly showing off the difference on the case from the original issue:
Screenshot 2026-06-12 at 3 36 13 PM

This case shows that it doesn't overpower the other bonuses, like the length bonus.
Screenshot 2026-06-12 at 3 36 06 PM

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • file_finder: Improved search results from fuzzy file search.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 12, 2026
@zed-community-bot zed-community-bot Bot added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Jun 12, 2026
@feitreim feitreim force-pushed the feat-tail-proximity-bonus branch from 9d5608a to bf0dd5e Compare June 12, 2026 20:09
@feitreim

feitreim commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Okay I have realized that this doesn't work for the x/x.py y/x.py case because nucleo handles single character querys differently than everything else... so it does work for real usage, but just not that little test example..

@ChristopherBiscardi ChristopherBiscardi added the area:search buffer search, project search, etc label Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:search buffer search, project search, etc cla-signed The user has signed the Contributor License Agreement guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fuzzy matching: double hits are not sorted higher

2 participants