# editor: Prioritize fuzzy score over sort positions in code completion sort \(\#35229\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/cf13a766184ebe334a275a4cafa35aac1394f2ac)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: cf13a766184ebe334a275a4cafa35aac1394f2ac

Requested commit: cf13a766184ebe334a275a4cafa35aac1394f2ac

Commit: cf13a766184ebe334a275a4cafa35aac1394f2ac

Tree: 5531b7c8297f217db9ed03bb2cdd145ce3f67d98

Author: Smit Barmase

Committer: GitHub

## Message

```
editor: Prioritize fuzzy score over sort positions in code completion sort (#35229)

We already prioritize matches that come after separators like `_`: 


https://github.com/zed-industries/zed/blob/cef7d53607381975ea00d6302d8a9aab3c40eb1f/crates/fuzzy/src/matcher.rs#L274

and deprioritize non-consecutive matches using distance penalty:


https://github.com/zed-industries/zed/blob/cef7d53607381975ea00d6302d8a9aab3c40eb1f/crates/fuzzy/src/matcher.rs#L281

In completion sort, letting fuzzy score be the primary sort factor and
sort positions be secondary yields better results upon testing. We still
need sort positions because of this kind of test case:


https://github.com/zed-industries/zed/blob/cef7d53607381975ea00d6302d8a9aab3c40eb1f/crates/editor/src/code_completion_tests.rs#L195-L217

Before/After:

<img height="250" alt="image"
src="https://github.com/user-attachments/assets/38495576-add6-4435-93f0-891f48ec9263"
/>
<img height="250" alt="image"
src="https://github.com/user-attachments/assets/0c73b835-0e23-4e30-a3ff-28bb56294239"
/>


Release Notes:

- N/A
```

## Parents

- [b64977f6f49a201dabd74b06e08f902981754f83](https://git.cafe/gitcafe/zed/commit/b64977f6f49a201dabd74b06e08f902981754f83?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/cf13a766184ebe334a275a4cafa35aac1394f2ac?format=markdown)
