# vim: Don't steal focus from non-pane panels for search commands \(\#54012\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/eb254be08433cd644c7ca7d582c5111995d62401)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: eb254be08433cd644c7ca7d582c5111995d62401

Requested commit: eb254be08433cd644c7ca7d582c5111995d62401

Commit: eb254be08433cd644c7ca7d582c5111995d62401

Tree: dafe8f23e92c20e89a1db1660cf3b68cf6330e34

Author: Richard Feldman

Committer: GitHub

## Message

```
vim: Don't steal focus from non-pane panels for search commands (#54012)

When the Agent panel (or any dock panel without its own pane) is focused
and a file is open in the center editor, pressing `/` in vim mode would
steal focus to the buffer's search bar instead of staying on the panel.

## Root cause

`Vim::pane()` calls `workspace.focused_pane()`, which falls back to the
center pane when a dock panel without its own `pane()` method is
focused. Vim search commands then open the `BufferSearchBar` on the
center pane and focus it, stealing focus from the panel.

## Fix

Add a guard in `Vim::pane()` that returns `None` when the resolved pane
doesn't actually contain focus. This prevents all vim search/match
commands (`/`, `?`, `n`, `N`, `*`, `#`, etc.) from stealing focus from
non-pane panels.

All 497 vim tests and 253 agent_ui tests pass.

Release Notes:

- Fixed vim search (`/`) stealing focus from the Agent panel when a file
is open in the editor.
```

## Parents

- [75fa566511e3ae7d03cfd76008512080291bd81d](https://git.cafe/gitcafe/zed/commit/75fa566511e3ae7d03cfd76008512080291bd81d?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/eb254be08433cd644c7ca7d582c5111995d62401?format=markdown)
