remove conditional action registration for activate semantic search mode

This commit is contained in:
KCaverly 2023-09-20 12:38:29 -04:00
parent 22d095bd35
commit 37a0c6615f
4 changed files with 16 additions and 17 deletions

View file

@ -370,8 +370,7 @@
}, },
// Difference settings for semantic_index // Difference settings for semantic_index
"semantic_index": { "semantic_index": {
"enabled": false, "enabled": false
"reindexing_delay_seconds": 600
}, },
// Different settings for specific languages. // Different settings for specific languages.
"languages": { "languages": {

View file

@ -71,9 +71,9 @@ pub fn init(cx: &mut AppContext) {
cx.add_action(ProjectSearchBar::activate_text_mode); cx.add_action(ProjectSearchBar::activate_text_mode);
// This action should only be registered if the semantic index is enabled // This action should only be registered if the semantic index is enabled
if SemanticIndex::enabled(cx) { // We are registering it all the time, as I dont want to introduce a dependency
// for Semantic Index Settings globally whenever search is tested.
cx.add_action(ProjectSearchBar::activate_semantic_mode); cx.add_action(ProjectSearchBar::activate_semantic_mode);
}
cx.capture_action(ProjectSearchBar::tab); cx.capture_action(ProjectSearchBar::tab);
cx.capture_action(ProjectSearchBar::tab_previous); cx.capture_action(ProjectSearchBar::tab_previous);
@ -1449,6 +1449,7 @@ impl ProjectSearchBar {
_: &ActivateSemanticMode, _: &ActivateSemanticMode,
cx: &mut ViewContext<Pane>, cx: &mut ViewContext<Pane>,
) { ) {
if SemanticIndex::enabled(cx) {
if let Some(search_view) = pane if let Some(search_view) = pane
.active_item() .active_item()
.and_then(|item| item.downcast::<ProjectSearchView>()) .and_then(|item| item.downcast::<ProjectSearchView>())
@ -1460,6 +1461,7 @@ impl ProjectSearchBar {
cx.propagate_action(); cx.propagate_action();
} }
} }
}
fn toggle_filters(&mut self, cx: &mut ViewContext<Self>) -> bool { fn toggle_filters(&mut self, cx: &mut ViewContext<Self>) -> bool {
if let Some(search_view) = self.active_project_search.as_ref() { if let Some(search_view) = self.active_project_search.as_ref() {

View file

@ -6,13 +6,11 @@ use settings::Setting;
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
pub struct SemanticIndexSettings { pub struct SemanticIndexSettings {
pub enabled: bool, pub enabled: bool,
pub reindexing_delay_seconds: usize,
} }
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)] #[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
pub struct SemanticIndexSettingsContent { pub struct SemanticIndexSettingsContent {
pub enabled: Option<bool>, pub enabled: Option<bool>,
pub reindexing_delay_seconds: Option<usize>,
} }
impl Setting for SemanticIndexSettings { impl Setting for SemanticIndexSettings {

View file

@ -156,8 +156,8 @@ fn main() {
project_panel::init(Assets, cx); project_panel::init(Assets, cx);
channel::init(&client); channel::init(&client);
diagnostics::init(cx); diagnostics::init(cx);
semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx);
search::init(cx); search::init(cx);
semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx);
vim::init(cx); vim::init(cx);
terminal_view::init(cx); terminal_view::init(cx);
copilot::init(copilot_language_server_id, http.clone(), node_runtime, cx); copilot::init(copilot_language_server_id, http.clone(), node_runtime, cx);