@@ -996,6 +996,10 @@ impl ProjectSearchBar {
SearchOption::Regex => &mut search_view.regex,
};
*value = !*value;
+
+ if value.clone() {
+ search_view.semantic = None;
+ }
search_view.search(cx);
});
cx.notify();
@@ -1012,6 +1016,9 @@ impl ProjectSearchBar {
search_view.semantic = None;
} else if let Some(semantic_index) = SemanticIndex::global(cx) {
// TODO: confirm that it's ok to send this project
+ search_view.regex = false;
+ search_view.case_sensitive = false;
+ search_view.whole_word = false;
let project = search_view.model.read(cx).project.clone();
let index_task = semantic_index.update(cx, |semantic_index, cx| {
@@ -1266,9 +1273,14 @@ impl View for ProjectSearchBar {
.with_child(self.render_nav_button(">", Direction::Next, cx))
.aligned(),
)
- .with_child(
- Flex::row()
- .with_child(self.render_semantic_search_button(cx))
+ .with_child({
+ let row = if SemanticIndex::enabled(cx) {
+ Flex::row().with_child(self.render_semantic_search_button(cx))
+ } else {
+ Flex::row()
+ };
+
+ let row = row
.with_child(self.render_option_button(
"Case",
SearchOption::CaseSensitive,
@@ -1286,8 +1298,10 @@ impl View for ProjectSearchBar {
))
.contained()
.with_style(theme.search.option_button_group)
- .aligned(),
- )
+ .aligned();
+
+ row
+ })
.contained()
.with_margin_bottom(row_spacing),
)
@@ -1,7 +1,7 @@
mod db;
mod embedding;
mod parsing;
-mod semantic_index_settings;
+pub mod semantic_index_settings;
#[cfg(test)]
mod semantic_index_tests;
@@ -183,6 +183,10 @@ impl SemanticIndex {
}
}
+ pub fn enabled(cx: &AppContext) -> bool {
+ settings::get::<SemanticIndexSettings>(cx).enabled
+ }
+
async fn new(
fs: Arc<dyn Fs>,
database_url: PathBuf,