zed
zed copied to clipboard
Ordering of search tokens in file finder fuzzy match
Check for existing issues
- [x] Completed
Describe the feature
Firstly, zed looks, feels, and works great! Thank you. I've been playing with it it since the Linux release and stumbled upon this muscle-memory quality-of-life enhancement.
Universally, fuzzy search in file finder widgets across editors are agnostic of the ordering of search tokens. For instance, the search inputs internal auth and auth internal should fuzzy-match the path /internal/auth. However, in the current version of zed (v0.143.7), the search is not ordering agnostic. In the above example, only internal auth produces a hit. Screenshots below.
Possibly related: https://github.com/zed-industries/zed/issues/7586
If applicable, add mockups / screenshots to help present your vision of the feature
Actual path: /internal/auth
Results for auth
Results for internal auth
Results for auth internal. Ideally, this should also produce the same result.
Comparison
vscode
Sublime
This! Often times, I look for a particular file, type the name of it, see that the search query is not specific enough so I add a parent folder name to the query. But in Zed that does not work, I have to type the folder name before the file name.
I would also like to add that already opened files should be preferred to other files. I might have a project with a dozen files named utils.c. Whenever I want to quickly switch to the particular utils.c I'm already editing, I either have to manually go through this list, or always remember to type the right prefix as well.
Alternatively, maybe we could get a "buffer search" command which only completes against already opened buffers.
No idea why migrations/patch/20250117120332009669-upsert_drug_dosage_admin.sql is not the first candidate.
As reported in https://github.com/zed-industries/zed/issues/18960 this also impacts the Assistant file picker.
Similarly with the Save dialog when using the fallback picker ("use_system_path_prompts": false,) as reported in https://github.com/zed-industries/zed/issues/20578:
May I ask when we can have a solution for this? In large projects, I usually try typing the file name first, then narrow down by its ancestor folders. Currently, Zed returns nothing unless I type the names in the same order of their path.
Also, humans usually type the first words in full, the last word tends to be partially matched. For example, given the following file structure:
api
|-- stable
|-- deals.ts
|-- developers.ts
|-- devices.ts
|-- details.ts
|-- alpha
|-- deals.ts
|-- developers.ts
|-- devices.ts
|-- details.ts
One would type deals, seeing there are multiple records in multiple folders: stable, and alpha, so just adding st or al to the query would return the desired result.
Now since Zed doesn't support this kind of behavior, one would need to type stable, and then see a bunch of files start with de => need to type more characters to get the desired result.
I know that this problem would also affect if the folders have a similar prefix, but again, it's less likely than files (i.e. leaf nodes).
In the end, it's a Find Finder, right? So, most of the time, the search query is file first - folder last, so... 🦀
Resources:
- https://github.com/oantolin/orderless?tab=readme-ov-file#component-matching-styles
- https://github.com/jojojames/fussy
Emacs (and packages) offers several well-known completion styles that take both recency and frequency into account when suggesting completions (both in filtering and sorting). In my opinion, it is currently the most flexible and accurate.
In large projects, I usually try typing the file name first, then narrow down by its ancestor folders.
I'm doing the same. I'm also migrating from Emacs and I'd love this feature to be implemented.
Unfortunately I don't know Rust and can't do it myself.
My recommendation for the zed devs is that this seems like a low hanging fruit that could potentially bring a lot of Emacs users to you.
The file finder's "order-matters" behaviour makes filtering results very difficult.
I typed init and got a list of __init__.py files. I wanted to find a specific file and knew a keyword in its path, so I added the keyword to my query: init mitm -- all the results disappear!
I'm moving to zed from nvim + fzf and this is the main thing I'm missing
I would say this is among the top 3 annoyances I have with Zed now.
Please implement query order independence for all selectors as well [1]. (I don't want to memorize how the command description has ordered the words)
Also, can we please have a "recency" ranking? Again across all selectors (where it make sense). Eg.: the command palette seems to be ordered by frequency only which is driving me crazy. The most recent command should be the first in the list when the query is empty.
As an example of a tool doing recency ranking well - take a look at Firefox.
[1] VSCode does not (and IIRC neither Jetbrains) even though they have it for the fileselector(?)