# editor: Use quantize score for code completions sort \+ Add code completions tests \(\#29182\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 0d3fe474db29a225e7f78bb172b7d70cc929ff5a

Requested commit: 0d3fe474db29a225e7f78bb172b7d70cc929ff5a

Commit: 0d3fe474db29a225e7f78bb172b7d70cc929ff5a

Tree: a348fa12f93645ee512c8958a95b498690b11713

Author: Smit Barmase

Committer: GitHub

## Message

```
editor: Use quantize score for code completions sort + Add code completions tests (#29182)

Closes #27994, #29050, #27352, #27616

This PR implements new logic for code completions, which improve cases
where local variables, etc LSP based hints are not shown on top of code
completion menu. The new logic is explained in comment of code.

This new sort is similar to VSCode's completions sort where order of
sort is like:

Fuzzy > Snippet > LSP sort_key > LSP sort_text 

whenever two items have same value, it proceeds to use next one as tie
breaker. Changing fuzzy score from float to int based makes it possible
for two items two have same fuzzy int score, making them get sorted by
next criteria.

Release Notes:

- Improved code completions to prioritize LSP hints, such as local
variables, so they appear at the top of the list.
```

## Parents

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

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