zed/crates/picker
HuaGu-Dragon 7b48fc6822
file_finder: Fix auto-jump to wrong file on hover via new set_hovered_index hook (#61716)
# Objective

- Fixes #54158 

## Solution

- The root cause is in `FileFinderDelegate::set_selected_index`: it
always sets `has_changed_selected_index = true`, regardless of whether
the selection change was triggered by keyboard navigation or mouse
hover.
- Fix: Added a separate `set_hovered_index` hook to the `PickerDelegate`
trait with a default implementation that delegates to
`set_selected_index`. The hover handler in Picker now calls
`set_hovered_index` instead of `set_selected_index`. FileFinderDelegate
overrides `set_hovered_index` to update `selected_index` without setting
`has_changed_selected_index`, so hover-triggered selection changes no
longer interfere with the `Cmd+P` auto-confirm logic.

## Testing

- Added `test_hover_does_not_set_has_changed_selected_index` in
`file_finder_tests.rs`

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed file finder auto-jumping to the wrong file when the mouse
hovered over a different entry after pressing `Cmd+P`
2026-08-19 15:04:31 +00:00
..
src file_finder: Fix auto-jump to wrong file on hover via new set_hovered_index hook (#61716) 2026-08-19 15:04:31 +00:00
Cargo.toml Improve overall compilation stats after the telescope picker feature (#60114) 2026-06-30 09:26:20 +00:00
LICENSE-GPL