create initial action for Semantic search mode
This commit is contained in:
parent
a366ad02ce
commit
912e6e8091
3 changed files with 27 additions and 4 deletions
|
@ -2,8 +2,8 @@ use crate::{
|
||||||
history::SearchHistory,
|
history::SearchHistory,
|
||||||
mode::{SearchMode, Side},
|
mode::{SearchMode, Side},
|
||||||
search_bar::{render_nav_button, render_option_button_icon, render_search_mode_button},
|
search_bar::{render_nav_button, render_option_button_icon, render_search_mode_button},
|
||||||
ActivateRegexMode, CycleMode, NextHistoryQuery, PreviousHistoryQuery, SearchOptions,
|
ActivateRegexMode, ActivateSemanticMode, CycleMode, NextHistoryQuery, PreviousHistoryQuery,
|
||||||
SelectNextMatch, SelectPrevMatch, ToggleCaseSensitive, ToggleWholeWord,
|
SearchOptions, SelectNextMatch, SelectPrevMatch, ToggleCaseSensitive, ToggleWholeWord,
|
||||||
};
|
};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
|
@ -63,6 +63,12 @@ pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(ProjectSearchBar::next_history_query);
|
cx.add_action(ProjectSearchBar::next_history_query);
|
||||||
cx.add_action(ProjectSearchBar::previous_history_query);
|
cx.add_action(ProjectSearchBar::previous_history_query);
|
||||||
cx.add_action(ProjectSearchBar::activate_regex_mode);
|
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);
|
||||||
cx.capture_action(ProjectSearchBar::tab_previous);
|
cx.capture_action(ProjectSearchBar::tab_previous);
|
||||||
add_toggle_option_action::<ToggleCaseSensitive>(SearchOptions::CASE_SENSITIVE, cx);
|
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 {
|
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() {
|
||||||
search_view.update(cx, |search_view, cx| {
|
search_view.update(cx, |search_view, cx| {
|
||||||
|
|
|
@ -39,7 +39,7 @@ actions!(
|
||||||
ActivateSemanticMode,
|
ActivateSemanticMode,
|
||||||
ActivateRegexMode,
|
ActivateRegexMode,
|
||||||
ReplaceAll,
|
ReplaceAll,
|
||||||
ReplaceNext
|
ReplaceNext,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
search::init(cx);
|
|
||||||
semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx);
|
semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx);
|
||||||
|
search::init(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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue