Files
zed/crates/vim/src
Parker Loflin a3ce8d5e88 search: Replace from the editor while buffer search is open (#67470)
## Summary

`search::ReplaceNext` and `search::ReplaceAll` only work while focus is
in the buffer search bar. Bound in the `buffer_search_deployed` context,
they do nothing from the editor, unlike `search::SelectNextMatch`.

Both actions are now registered for the pane, like the other search
actions. Inside and outside the search bar, they run only while the
replace input is visible, so a hidden replacement can't overwrite
matches.

Workspace-level search actions now go to the focused pane instead of the
center pane, so search actions in the terminal panel no longer act on
the editor's search bar. `Workspace::focused_pane` now also finds zoomed
dock panels, which render outside their dock. The debug panel has no
`Panel::pane`, so its Terminal tab still sends them to the editor's
search bar, as on `main`.

With vim mode on, `vim::SearchSubmit` now propagates when the focused
pane has no vim editor or does not contain the focus, so `enter` selects
the next match in the search bars of the terminal panel and the
debugger's Terminal tab.

Closes #66518

## Testing

- To reproduce, bind `ctrl-r` to `search::ReplaceNext` in the
`buffer_search_deployed` context, open the search bar in replace mode,
fill in both fields, focus the editor, and press `ctrl-r`. Nothing
happens.
- Tested on Linux. On `main`, neither action changes the buffer. On this
branch, `search::ReplaceNext` replaces one match per press and
`search::ReplaceAll` replaces the rest.
- The test dispatches both actions from the editor, from the search bar
with the replace input hidden, and from a docked and a zoomed panel with
its own pane and a panel without one, then checks the buffer text and
the replace toggle.
- Each part of `test_replace_with_editor_focused` fails without its fix.
- `test_search_submit_without_vim_editor` presses `enter` in the search
bar of an editor without vim and checks that the next match is selected.
It fails without the fix.
- `test_search_submit_outside_pane` does the same in a search bar
outside the panes, with a vim editor in the center pane.
  It fails without the focus check.
- `cargo test -p search -p workspace -p file_finder -p terminal_view -p
vim --lib` and `./script/clippy -p search -p workspace -p vim` pass.

## 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.

Release Notes:

- Fixed `search::ReplaceNext` and `search::ReplaceAll` doing nothing
when the editor is focused while the buffer search bar is open, search
actions in the terminal panel acting on the editor's search bar, and
`enter` not selecting the next match in terminal search bars with Vim
mode on


https://github.com/user-attachments/assets/69be3dc7-9fb7-4c45-9aea-e6799db9725d

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2026-11-26 00:21:02 +00:00
..
…
…
…
…
…
…