zed/crates/open_path_prompt
Arti 708c7eef55
file_finder: Implement SeedQuerySetting::Selection seed_query (#64946)
## Summary

UX parity with JetBrains IDEs: there, you can
- select a file name/path in the terminal/editor
- press the "open file finder" hotkey
- see search results for that file

On Zed's main branch, you have to:
- select a file name/path in the terminal/editor
- press ctrl+c / ctrl+shift+c (depending on the context)
- press the "open file finder" hotkey
- see the default list of files for an empty search
- press ctrl+v
- see search results for that file

The issue is little one but it is a "death by a thousand cuts" type of
straw for me.


https://github.com/user-attachments/assets/26de5bba-98c2-4a1f-8540-1e0e646301e8

The feature can be disabled in the `settings.json` with the
`file_finder.prefill_query_from_selection` flag set to `false` or in the
settings UI page for file finder.

## Testing

To test this, a reviewer can:
- open any project
- select a file name/path in the terminal/editor
- press the "open file finder" hotkey
- see search results for that file

Then switch the checkbox in the file finder setting page (or set
`file_finder.prefill_query_from_selection` to `false` in settings.json)
and:
- select a file name/path in the terminal/editor
- press the "open file finder" hotkey
- see the default list of files for an empty search

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.


Zed already has a `seed_query` mechanism for `text_finder`, built on
`SeedQuerySetting::Selection` and
`SearchableItemHandle::query_suggestion`, which I reused as much as
possible.

`FileFinder::seed_query` basically duplicates
`TextFinder::active_item_query` code (except checking if the setting is
disabled).

I wanted to unify the functionality but did not know where the new
unified method would fit better and decided that some code duplication
is not as terrible as bad refactor (if any reviewer can tell me a proper
place to put the method to get selected text for search query I will be
very thankful).

Ran every existing test (- each passed) and asked LLM generate new ones
for this PR (reviewed them and can vouch that they make sense)

Release Notes:

- Improved the file finder to pre-fill the search query with the text
selected in the terminal/editor
- [GPUI] Added a method for retrieving the selected text from any
registered input handler

---------

Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
2026-10-03 00:28:21 +00:00
..
src file_finder: Implement SeedQuerySetting::Selection seed_query (#64946) 2026-10-03 00:28:21 +00:00
Cargo.toml Fix cargo shear warnings (#64340) 2026-09-17 08:49:31 +00:00
LICENSE-GPL