Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
create initial action for Semantic search mode
KCaverly912e6e809191
diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rsindex 19442191172..eca99fa16d5 100644--- a/crates/search/src/project_search.rs+++ b/crates/search/src/project_search.rs@@ -2,8 +2,8 @@ use crate::{history::SearchHistory,mode::{SearchMode, Side},search_bar::{render_nav_button, render_option_button_icon, render_search_mode_button},- ActivateRegexMode, CycleMode, NextHistoryQuery, PreviousHistoryQuery, SearchOptions,- SelectNextMatch, SelectPrevMatch, ToggleCaseSensitive, ToggleWholeWord,+ ActivateRegexMode, ActivateSemanticMode, CycleMode, NextHistoryQuery, PreviousHistoryQuery,+ SearchOptions, SelectNextMatch, SelectPrevMatch, ToggleCaseSensitive, ToggleWholeWord,};use anyhow::{Context, Result};use collections::HashMap;@@ -63,6 +63,12 @@ pub fn init(cx: &mut AppContext) {cx.add_action(ProjectSearchBar::next_history_query);cx.add_action(ProjectSearchBar::previous_history_query);cx.add_action(ProjectSearchBar::activate_regex_mode);++ // This action should only be registered if the semantic index is enabled+ if SemanticIndex::enabled(cx) {+ cx.add_action(ProjectSearchBar::activate_semantic_mode);+ }+cx.capture_action(ProjectSearchBar::tab);cx.capture_action(ProjectSearchBar::tab_previous);add_toggle_option_action::<ToggleCaseSensitive>(SearchOptions::CASE_SENSITIVE, cx);@@ -1348,6 +1354,23 @@ impl ProjectSearchBar {}}+ fn activate_semantic_mode(+ pane: &mut Pane,+ _: &ActivateSemanticMode,+ cx: &mut ViewContext<Pane>,+ ) {+ if let Some(search_view) = pane+ .active_item()+ .and_then(|item| item.downcast::<ProjectSearchView>())+ {+ search_view.update(cx, |view, cx| {+ view.activate_search_mode(SearchMode::Semantic, cx)+ });+ } else {+ cx.propagate_action();+ }+ }+fn toggle_filters(&mut self, cx: &mut ViewContext<Self>) -> bool {if let Some(search_view) = self.active_project_search.as_ref() {search_view.update(cx, |search_view, cx| {diff --git a/crates/search/src/search.rs b/crates/search/src/search.rsindex dabbc720cea..ba06b3f9c77 100644--- a/crates/search/src/search.rs+++ b/crates/search/src/search.rs@@ -39,7 +39,7 @@ actions!(ActivateSemanticMode,ActivateRegexMode,ReplaceAll,- ReplaceNext+ ReplaceNext,]);diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rsindex d22e26c1f56..98bf600a618 100644--- a/crates/zed/src/main.rs+++ b/crates/zed/src/main.rs@@ -156,8 +156,8 @@ fn main() {project_panel::init(Assets, cx);channel::init(&client);diagnostics::init(cx);- search::init(cx);semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx);+ search::init(cx);vim::init(cx);terminal_view::init(cx);copilot::init(copilot_language_server_id, http.clone(), node_runtime, cx);