diff --git a/crates/search/src/mode.rs b/crates/search/src/mode.rs index aaaebc6e860b6d91bdc3bc972c2064c45e4889f0..072b9ffd804ee977396d80bbf38b3d944f91e249 100644 --- a/crates/search/src/mode.rs +++ b/crates/search/src/mode.rs @@ -71,3 +71,17 @@ impl SearchMode { } } } + +pub(crate) fn next_mode(mode: &SearchMode, semantic_enabled: bool) -> SearchMode { + let next_text_state = if semantic_enabled { + SearchMode::Semantic + } else { + SearchMode::Regex + }; + + match mode { + SearchMode::Text => next_text_state, + SearchMode::Semantic => SearchMode::Regex, + SearchMode::Regex => SearchMode::Text, + } +} diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 4852e7700408f7f91db2ca0392f8d64b06ebd4c8..97b9f7b75bfa90989fc1988783ad752972358e3f 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -1155,18 +1155,8 @@ impl ProjectSearchBar { .and_then(|item| item.downcast::()) { search_view.update(cx, |this, cx| { - let mode = &this.current_mode; - let next_text_state = if SemanticIndex::enabled(cx) { - SearchMode::Semantic - } else { - SearchMode::Regex - }; - - let new_mode = match mode { - &SearchMode::Text => next_text_state, - &SearchMode::Semantic => SearchMode::Regex, - SearchMode::Regex => SearchMode::Text, - }; + let new_mode = + crate::mode::next_mode(&this.current_mode, SemanticIndex::enabled(cx)); this.activate_search_mode(new_mode, cx); }) }