diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 1c1f1e974a63037006ea7352d441dee97e8ac44b..66f473d829537e60f5567d1383f3fadcfc12fe7c 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -840,6 +840,10 @@ impl BufferSearchBar { } } + pub fn has_active_match(&self) -> bool { + self.active_match_index.is_some() + } + fn clear_matches(&mut self, cx: &mut ViewContext) { let mut active_item_matches = None; for (searchable_item, matches) in self.searchable_items_with_matches.drain() { diff --git a/crates/vim/src/normal/search.rs b/crates/vim/src/normal/search.rs index d7277a52ef2f0de4e1d3e9ad41228e2e5392e3fe..cc783e6120d6ef274f67a6155a886ac83b3d70f5 100644 --- a/crates/vim/src/normal/search.rs +++ b/crates/vim/src/normal/search.rs @@ -218,6 +218,9 @@ pub fn move_to_match_internal( pane.update(cx, |pane, cx| { if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::() { search_bar.update(cx, |search_bar, cx| { + if !search_bar.has_active_match() || !search_bar.show(cx) { + return; + } search_bar.select_match(direction, count, cx); let new_selections = vim.editor_selections(cx); diff --git a/crates/vim/src/visual.rs b/crates/vim/src/visual.rs index 9e9a8b4474d531ea0ac1f4b10d4b8f0448cba556..51161a6bf802c578dd28fa8008a8fd6eeb47503a 100644 --- a/crates/vim/src/visual.rs +++ b/crates/vim/src/visual.rs @@ -516,6 +516,9 @@ pub fn select_match( pane.update(cx, |pane, cx| { if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::() { search_bar.update(cx, |search_bar, cx| { + if !search_bar.has_active_match() || !search_bar.show(cx) { + return; + } // without update_match_index there is a bug when the cursor is before the first match search_bar.update_match_index(cx); search_bar.select_match(direction.opposite(), 1, cx);