Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve autocompletion order #5013

Closed
1 task done
WeetHet opened this issue Feb 9, 2023 · 16 comments · Fixed by #2169 or #7727
Closed
1 task done

Improve autocompletion order #5013

WeetHet opened this issue Feb 9, 2023 · 16 comments · Fixed by #2169 or #7727
Assignees
Labels
editor Feedback for code editing, formatting, editor iterations, etc enhancement [core label]

Comments

@WeetHet
Copy link
Contributor

WeetHet commented Feb 9, 2023

Check for existing issues

  • Completed

Describe the feature

In VSCode rust-ananlyzer puts Vec type before vec! macro when autocompleting something like

fn main() {
    let x: V
}

In Zed autocomplete order also definitely should respect at least the case of item being autocompleted, and if possible also try rearanging completions arrording to some heuristic or maybe even some pretrained neural network, which would assign weight to completions

Also, using macros for types is quite rare, so they can be moved down

If applicable, add mockups / screenshots to help present your vision of the feature

Screenshot 2023-02-09 at 17 43 25

Screenshot 2023-02-09 at 17 42 42

@WeetHet WeetHet added enhancement [core label] triage Maintainer needs to classify the issue labels Feb 9, 2023
@JosephTLyons JosephTLyons added editor Feedback for code editing, formatting, editor iterations, etc and removed triage Maintainer needs to classify the issue labels Feb 9, 2023
@TENX-S
Copy link
Contributor

TENX-S commented Feb 15, 2023

same issue with golang:
image

@as-cii
Copy link
Member

as-cii commented Feb 15, 2023

A fix for this will go out with the next release. Thanks so much for the feedback! 🙏

@mikayla-maki mikayla-maki reopened this Mar 8, 2023
@mikayla-maki
Copy link
Contributor

mikayla-maki commented Mar 8, 2023

Strangely, this seems to still not be fixed.

From the discord, I verified this behavior as well:

Screenshot_2023-03-07_at_11 46 31

@victor-teles
Copy link

I think it would be great if it suggest typescript primitives types first too (for me at least, I use primitives more often)

CleanShot 2023-10-30 at 20 31 28@2x

@Snap45dragon
Copy link

Snap45dragon commented Jan 18, 2024

Similar issue in vue template files while autocompleting imported components
Screenshot 2024-01-18 at 2 27 41 PM

@JosephTLyons JosephTLyons transferred this issue from zed-industries/community Jan 24, 2024
@DannyJJK
Copy link

Similar issue with PHP (in this case using the Laravel framework).

I start typing whereBetween however the first result on the autocomplete is orWhereBetween and the actual one I want is further down.

image

@mrnugget
Copy link
Member

Just to record this here: Theo also mentioned this in his video

screenshot-2024-02-13-10 18 38@2x

@DannyJJK
Copy link

This seems to affect the project file search (cmd+p) as well. Here I search for the file mi.php and it's the third option down when it should really be the first one. The first suggestion here doesn't make sense given it's only a partial match:
image

mrnugget added a commit that referenced this issue Feb 13, 2024
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

Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: bennetbo <bennetbo@gmx.de>
@mrnugget
Copy link
Member

mrnugget commented Feb 13, 2024

@DannyJJK that last one, that's a different issue: we rank recent items higher. There's a very thin line after the first 2 results. Admittedly, it's really hard to spot and we should probably improve that UI.


In #7727 we just made some improvements that should help with the bug that Theo reported and some of the others reported in here (string/String and UIAlert). The vec vs. Vec thing in Rust is still unchanged (and matches VS Code btw.!)

mrnugget added a commit that referenced this issue Feb 13, 2024
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](#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>
@mrnugget
Copy link
Member

We just merged #7727 and it attempts to fix the order.

If problems like this pop up again, I think it would be best to have separate issues with clear descriptions on how to reproduce the problem and what the expected/actual behavior are, since there's a lot of nuance in how these completions are sorted and we don't want to make something worse by loosely making something else better :)

@Dorjderem2002
Copy link

Same problem happens with C++ too.

@mrnugget
Copy link
Member

Same problem happens with C++ too.

Can you provide more information? i.e. what did you type, what did you expect to see, what did you see instead, etc.?

@Dorjderem2002
Copy link

Dorjderem2002 commented Mar 9, 2024

Same problem happens with C++ too.

Can you provide more information? i.e. what did you type, what did you expect to see, what did you see instead, etc.?

Sure, when I write "for" it does not show for loop instead it shows for_each function. I assume for loop should be most used. And I never used for_each in my project or file so it is recommending it out of nowhere. Zed version 0.125.3
Uploading Screenshot 2024-03-09 at 4.59.28 PM.png…

@mrnugget
Copy link
Member

I can't see that screenshot, but that does sound like an issue. Like I wrote above:

I think it would be best to have separate issues with clear descriptions on how to reproduce the problem and what the expected/actual behavior are

Can you create a new ticket for this?

@bernardinorafael
Copy link

Same here, not fixed yet...

image

@mrnugget
Copy link
Member

mrnugget commented Apr 2, 2024

@bernardinorafael can you create a ticket with a minimal reproducible example, what you expect to see, what you get instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor Feedback for code editing, formatting, editor iterations, etc enhancement [core label]
Projects
None yet