From 36b9e400852b47fe9464eb445c17cd2f1957d3c0 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Fri, 11 Oct 2024 10:06:33 +0200 Subject: [PATCH] vim: Reset search options whenever `/` is used (#19058) This is a bit of a personal thing, but it's been bugging me for a while now that the search options are sticky whenever I use `/` in Vim mode. This change makes it so that the options are reset with each new `/`. That means you can, for example, use `v` to create a visual selection, then hit `*` to search for that (which activates a bunch of search options), but then continue with `/` to get a normal search. Release Notes: - Changed `/` in Vim mode to always reset the search options in the search bar back to regex-only. That means using `*` (in normal or visual mode) still works with its options, but the next `/` will reset the search options. That makes it much closer to how `/` behaves in Vim. --- crates/vim/src/normal/search.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/vim/src/normal/search.rs b/crates/vim/src/normal/search.rs index 6769238407..364e29242b 100644 --- a/crates/vim/src/normal/search.rs +++ b/crates/vim/src/normal/search.rs @@ -129,14 +129,13 @@ impl Vim { search_bar.select_query(cx); cx.focus_self(); - if query.is_empty() { - search_bar.set_replacement(None, cx); - search_bar.set_search_options(SearchOptions::REGEX, cx); - } + search_bar.set_replacement(None, cx); + search_bar.set_search_options(SearchOptions::NONE | SearchOptions::REGEX, cx); + self.search = SearchState { direction, count, - initial_query: query.clone(), + initial_query: query, prior_selections, prior_operator: self.operator_stack.last().cloned(), prior_mode: self.mode,