Move mode cycling to mode module
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1155,18 +1155,8 @@ impl ProjectSearchBar {
|
||||
.and_then(|item| item.downcast::<ProjectSearchView>())
|
||||
{
|
||||
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);
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user