zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
48.78k stars 2.93k forks source link

Improve autocompletion order #5013

Closed WeetHet closed 8 months ago

WeetHet commented 1 year ago

Check for existing issues

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
TENX-S commented 1 year ago

same issue with golang:

image
as-cii commented 1 year ago

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

mikayla-maki commented 1 year ago

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 commented 11 months ago

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 commented 9 months ago

Similar issue in vue template files while autocompleting imported components

Screenshot 2024-01-18 at 2 27 41 PM
DannyJJK commented 8 months ago

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 commented 8 months ago

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

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

DannyJJK commented 8 months ago

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 commented 8 months ago

@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 https://github.com/zed-industries/zed/pull/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 commented 8 months ago

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 commented 7 months ago

Same problem happens with C++ too.

mrnugget commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 6 months ago

Same here, not fixed yet...

image
mrnugget commented 6 months ago

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

wolfadex commented 4 months ago

I've created a new ticket https://github.com/zed-industries/zed/issues/12590 with steps to reproduce in Elm

Benjamin-van-Heerden commented 3 months ago

Tailwind completion order is really not great as well

image

It should be suggesting just "px-2,..." when I scroll down, they are there, but this should be the first suggestion

tinrab commented 2 months ago

Can somebody else confirm that this is still an issue? This was addressed in #2169, but it breaks completions for me. If I enable "smart case" in fuzzy::match_strings, meaning it's always true, then completions seem to work as expected. I've tested it for Rust and TypeScript.

bernardinorafael commented 2 months ago

@tinrab

running ok for me (zed 0.147.2)

TeoBale commented 1 month ago

Running version 0.151.2 I realize that the autocomplete order is really inconvenient...

I noticed this by trying zed in tailwind and typescript