Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions crates/vim/src/normal/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,4 +1446,41 @@ mod test {
// The cursor should be at the match location on line 3 (row 2).
cx.assert_state("hello world\nfoo bar\nhello ˇagain\n", Mode::Normal);
}


#[gpui::test]
async fn test_helix_search_dismiss_on_escape(cx: &mut gpui::TestAppContext) {
let mut cx = VimTestContext::new(cx, true).await;
cx.set_state("ˇhello world
foo bar
hello again
", Mode::HelixNormal);

// Open search
cx.simulate_keystrokes("/");
cx.run_until_parked();

// Type query and submit
cx.simulate_keystrokes("h e l l o");
cx.run_until_parked();
cx.simulate_keystrokes("enter");
cx.run_until_parked();

// Search bar should be dismissed (like Vim mode), verify escape works
cx.simulate_keystrokes("escape");
cx.run_until_parked();

// Verify search bar is dismissed
cx.workspace(|workspace, _window, cx| {
let pane = workspace.active_pane().read(cx);
let search_bar = pane
.toolbar()
.read(cx)
.item_of_type::<search::BufferSearchBar>();
assert!(
search_bar.is_none_or(|bar| bar.read(cx).is_dismissed()),
"Search bar should be dismissed after pressing Escape in Helix normal mode"
);
});
}
}
21 changes: 20 additions & 1 deletion crates/vim/src/vim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,26 @@ impl Vim {
editor,
cx,
|vim, _: &SwitchToHelixNormalMode, window, cx| {
vim.switch_mode(Mode::HelixNormal, true, window, cx)
vim.switch_mode(Mode::HelixNormal, true, window, cx);
// Dismiss the search bar on Escape, matching Vim's behavior
// where editor::Cancel propagates to dismiss the search bar.
if let Some(pane) = vim.pane(window, cx) {
pane.update(cx, |pane, cx| {
if let Some(search_bar) =
pane.toolbar().read(cx).item_of_type::<BufferSearchBar>()
{
search_bar.update(cx, |bar, cx| {
if !bar.is_dismissed() {
bar.dismiss(
&search::buffer_search::Dismiss,
window,
cx,
);
}
});
}
});
}
},
);
Vim::action(editor, cx, |_, _: &PushForcedMotion, _, cx| {
Expand Down
Loading