2023-11-13 19:38:37 +00:00
|
|
|
// TODO: Update the default search mode to get from config
|
|
|
|
#[derive(Copy, Clone, Debug, Default, PartialEq)]
|
|
|
|
pub enum SearchMode {
|
|
|
|
#[default]
|
|
|
|
Text,
|
|
|
|
Semantic,
|
|
|
|
Regex,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl SearchMode {
|
2023-11-17 16:22:52 +00:00
|
|
|
pub(crate) fn label(&self) -> &'static str {
|
2023-11-13 19:38:37 +00:00
|
|
|
match self {
|
2023-11-17 16:22:52 +00:00
|
|
|
SearchMode::Text => "Text",
|
|
|
|
SearchMode::Semantic => "Semantic",
|
|
|
|
SearchMode::Regex => "Regex",
|
2023-11-13 19:38:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn next_mode(mode: &SearchMode, semantic_enabled: bool) -> SearchMode {
|
|
|
|
match mode {
|
|
|
|
SearchMode::Text => SearchMode::Regex,
|
|
|
|
SearchMode::Regex => {
|
|
|
|
if semantic_enabled {
|
|
|
|
SearchMode::Semantic
|
|
|
|
} else {
|
|
|
|
SearchMode::Text
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SearchMode::Semantic => SearchMode::Text,
|
|
|
|
}
|
|
|
|
}
|