Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
vim: Enter/n/N to navigate search results
Conrad Irwin96ce0bb78338
diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.jsonindex 84f9689c2cb..72aa7194080 100644--- a/assets/keymaps/vim.json+++ b/assets/keymaps/vim.json@@ -60,6 +60,8 @@"ignorePunctuation": true}],+ "n": "search::SelectNextMatch",+ "shift-n": "search::SelectPrevMatch","%": "vim::Matching","f": ["vim::PushOperator",@@ -335,5 +337,11 @@"Normal"]}+ },+ {+ "context": "BufferSearchBar",+ "bindings": {+ "enter": "buffer_search::FocusEditor"+ }}]diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rsindex 95962f85b89..d9d24ec30ee 100644--- a/crates/vim/src/test.rs+++ b/crates/vim/src/test.rs@@ -5,6 +5,7 @@ mod vim_binding_test_context;mod vim_test_context;use command_palette::CommandPalette;+use editor::DisplayPoint;pub use neovim_backed_binding_test_context::*;pub use neovim_backed_test_context::*;pub use vim_binding_test_context::*;@@ -153,3 +154,44 @@ async fn test_escape_command_palette(cx: &mut gpui::TestAppContext) {assert!(!cx.workspace(|workspace, _| workspace.modal::<CommandPalette>().is_some()));cx.assert_state("aˇbc\n", Mode::Insert);}++#[gpui::test]+async fn test_selection_on_search(cx: &mut gpui::TestAppContext) {+ let mut cx = VimTestContext::new(cx, true).await;++ cx.set_state(indoc! {"aa\nbˇb\ncc\ncc\ncc\n"}, Mode::Normal);+ cx.simulate_keystrokes(["/", "c", "c"]);++ let search_bar = cx.workspace(|workspace, cx| {+ workspace+ .active_pane()+ .read(cx)+ .toolbar()+ .read(cx)+ .item_of_type::<BufferSearchBar>()+ .expect("Buffer search bar should be deployed")+ });++ search_bar.read_with(cx.cx, |bar, cx| {+ assert_eq!(bar.query_editor.read(cx).text(cx), "cc");+ });++ // wait for the query editor change event to fire.+ search_bar.next_notification(&cx).await;++ cx.update_editor(|editor, cx| {+ let highlights = editor.all_background_highlights(cx);+ assert_eq!(3, highlights.len());+ assert_eq!(+ DisplayPoint::new(2, 0)..DisplayPoint::new(2, 2),+ highlights[0].0+ )+ });+ cx.simulate_keystrokes(["enter"]);++ cx.assert_state(indoc! {"aa\nbb\nˇcc\ncc\ncc\n"}, Mode::Normal);+ cx.simulate_keystrokes(["n"]);+ cx.assert_state(indoc! {"aa\nbb\ncc\nˇcc\ncc\n"}, Mode::Normal);+ cx.simulate_keystrokes(["shift-n"]);+ cx.assert_state(indoc! {"aa\nbb\nˇcc\ncc\ncc\n"}, Mode::Normal);+}