# helix: Fix \`buffer search: deploy\` reset to normal mode \(\#36917\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 0e575b280997b346e58497725fa0609ac4f6f47c

Requested commit: 0e575b280997b346e58497725fa0609ac4f6f47c

Commit: 0e575b280997b346e58497725fa0609ac4f6f47c

Tree: 431f0f07e6c50d821d34424ba71aa1952f102779

Author: Adam Mulvany

Committer: GitHub

## Message

````
helix: Fix `buffer search: deploy` reset to normal mode (#36917)

## Fix: Preserve Helix mode when using  search

### Problem
When using `buffer search: deploy` in Helix mode, pressing Enter to
dismiss the search incorrectly returned to Vim NORMAL mode instead of
Helix NORMAL mode.

### Root Cause
The `search_deploy` function was resetting the entire `SearchState` to
default values when buffer search: deploy was activated. Since the
default `Mode` is `Normal`, this caused `prior_mode` to be set to Vim's
Normal mode regardless of the actual mode before search.

### Solution
Modified `search_deploy` to preserve the current mode when resetting
search state:
- Store the current mode before resetting
- Reset search state to default
- Restore the saved mode to `prior_mode`

This ensures the editor returns to the correct mode (Helix NORMAL or Vim
NORMAL) after dismissing buffer search.

### Settings

I was able to reproduce and then test the fix was successful with the
following config and have also tested with vim: default_mode commented
out to ensure that's not influencing the mode selection flow:

```
  "helix_mode": true,
  "vim_mode": true,
  "vim": {
    "default_mode": "helix_normal"
  },
```

This is on Kubuntu 24.04.

The following test combinations pass locally:

- `cargo test -p search`
- `cargo test -p vim` 
- `cargo test -p editor`
- `cargo test -p workspace`
- `cargo test -p gpui -- vim`
- `cargo test -p gpui -- helix`

Release Notes:

- Fixed Helix mode switching to Vim normal mode after using `buffer
search: deploy` to search

Closes #36872
````

## Parents

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

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