diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 12b283ab22937b7952d18d63b1378d2914211f9b..7be63c5c3516e4ba60057a70aba2c6840a3256b0 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -786,6 +786,9 @@ impl BufferSearchBar { self.default_options = configured_options; } + // This isn't a normal setting; it's only applicable to vim search. + self.search_options.remove(SearchOptions::BACKWARDS); + self.dismissed = false; self.adjust_query_regex_language(cx); handle.search_bar_visibility_changed(true, window, cx); @@ -958,6 +961,10 @@ impl BufferSearchBar { Some(self.update_matches(false, false, window, cx)) } + pub fn search_options(&self) -> SearchOptions { + self.search_options + } + pub fn set_search_options(&mut self, search_options: SearchOptions, cx: &mut Context) { self.search_options = search_options; self.adjust_query_regex_language(cx); diff --git a/crates/vim/src/normal/search.rs b/crates/vim/src/normal/search.rs index 36a529da5da4be4ea3437a766daa1bc18bcfdd68..23d61017f51343cdf357859f63f39d330c911e46 100644 --- a/crates/vim/src/normal/search.rs +++ b/crates/vim/src/normal/search.rs @@ -49,8 +49,6 @@ pub(crate) struct MoveToPrevious { pub(crate) struct Search { #[serde(default)] backwards: bool, - #[serde(default = "default_true")] - regex: bool, } /// Executes a find command to search for patterns in the buffer. @@ -99,6 +97,7 @@ pub(crate) fn register(editor: &mut Editor, cx: &mut Context) { Vim::action(editor, cx, Vim::move_to_previous_match); Vim::action(editor, cx, Vim::search); Vim::action(editor, cx, Vim::search_deploy); + Vim::action(editor, cx, Vim::find_command); Vim::action(editor, cx, Vim::replace_command); } @@ -172,17 +171,13 @@ impl Vim { cx.focus_self(window); search_bar.set_replacement(None, cx); - let mut options = SearchOptions::NONE; - if action.regex { - options |= SearchOptions::REGEX; - } if action.backwards { - options |= SearchOptions::BACKWARDS; - } - if EditorSettings::get_global(cx).search.case_sensitive { - options |= SearchOptions::CASE_SENSITIVE; + search_bar.set_search_options( + search_bar.search_options() | SearchOptions::BACKWARDS, + cx, + ); } - search_bar.set_search_options(options, cx); + let prior_mode = if self.temp_mode { Mode::Insert } else {