# Improve sorting of completion results \(\#7727\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 798c9a7d8b32d40dec07788ca85bf5141409547b

Requested commit: 798c9a7d8b32d40dec07788ca85bf5141409547b

Commit: 798c9a7d8b32d40dec07788ca85bf5141409547b

Tree: e04edf6faee24d82b5c42c03a4d93dd24a9e2738

Author: Thorsten Ball

Committer: GitHub

## Message

```
Improve sorting of completion results (#7727)

This is an attempt to fix #5013 by doing two things:

1. Rank "obvious" matches in completions higher (see the code comment)
2. When tied: rank keywords higher than variables

Release Notes:

- Improved sorting of completion results to prefer literal matches.
([#5013](https://github.com/zed-industries/zed/issues/5013)).

### Before

![screenshot-2024-02-13-13 08
13@2x](https://github.com/zed-industries/zed/assets/1185253/77decb0b-5b47-45de-ab69-f7b333072b45)
![screenshot-2024-02-13-13 10
42@2x](https://github.com/zed-industries/zed/assets/1185253/ae33d0fe-06f5-4fc1-84f8-ddf6dbe80ba5)


### After

![screenshot-2024-02-13-13 06
22@2x](https://github.com/zed-industries/zed/assets/1185253/3c526bab-6392-4eeb-a2f2-dd73ccf228e8)
![screenshot-2024-02-13-13 06
50@2x](https://github.com/zed-industries/zed/assets/1185253/b5b9d513-766d-4a53-94de-b46271f5978c)

Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: bennetbo <bennetbo@gmx.de>
```

## Parents

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

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