diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index df6e7e7d6a8f8..701995b0e38b3 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -1220,7 +1220,7 @@ impl BufferSearchBar { } } - fn replace_next(&mut self, _: &ReplaceNext, cx: &mut ViewContext) { + pub fn replace_next(&mut self, _: &ReplaceNext, cx: &mut ViewContext) { let mut should_propagate = true; if !self.dismissed && self.active_search.is_some() { if let Some(searchable_item) = self.active_searchable_item.as_ref() { diff --git a/crates/vim/src/normal/search.rs b/crates/vim/src/normal/search.rs index fb6bd6a93b4ae..2e047c029de3c 100644 --- a/crates/vim/src/normal/search.rs +++ b/crates/vim/src/normal/search.rs @@ -421,28 +421,30 @@ impl Vim { cx.spawn(|_, mut cx| async move { search.await?; search_bar.update(&mut cx, |search_bar, cx| { + search_bar.select_last_match(cx); if replacement.should_replace_all { - search_bar.select_last_match(cx); search_bar.replace_all(&Default::default(), cx); - cx.spawn(|_, mut cx| async move { - cx.background_executor() - .timer(Duration::from_millis(200)) - .await; - editor - .update(&mut cx, |editor, cx| editor.clear_search_within_ranges(cx)) - .ok(); - }) - .detach(); - vim.update(cx, |vim, cx| { - vim.move_cursor( - Motion::StartOfLine { - display_lines: false, - }, - None, - cx, - ) - }); + } else { + search_bar.replace_next(&Default::default(), cx); } + cx.spawn(|_, mut cx| async move { + cx.background_executor() + .timer(Duration::from_millis(200)) + .await; + editor + .update(&mut cx, |editor, cx| editor.clear_search_within_ranges(cx)) + .ok(); + }) + .detach(); + vim.update(cx, |vim, cx| { + vim.move_cursor( + Motion::StartOfLine { + display_lines: false, + }, + None, + cx, + ) + }); })?; anyhow::Ok(()) })