add keymaps for activating text, regex and semantic modes
This commit is contained in:
parent
912e6e8091
commit
28ed406d54
2 changed files with 29 additions and 5 deletions
|
@ -248,7 +248,10 @@
|
||||||
"context": "ProjectSearchBar",
|
"context": "ProjectSearchBar",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"escape": "project_search::ToggleFocus",
|
"escape": "project_search::ToggleFocus",
|
||||||
"alt-tab": "search::CycleMode"
|
"alt-tab": "search::CycleMode",
|
||||||
|
"alt-cmd-g": "search::ActivateRegexMode",
|
||||||
|
"alt-cmd-s": "search::ActivateSemanticMode",
|
||||||
|
"alt-cmd-x": "search::ActivateTextMode"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -262,7 +265,10 @@
|
||||||
"context": "ProjectSearchView",
|
"context": "ProjectSearchView",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"escape": "project_search::ToggleFocus",
|
"escape": "project_search::ToggleFocus",
|
||||||
"alt-tab": "search::CycleMode"
|
"alt-tab": "search::CycleMode",
|
||||||
|
"alt-cmd-g": "search::ActivateRegexMode",
|
||||||
|
"alt-cmd-s": "search::ActivateSemanticMode",
|
||||||
|
"alt-cmd-x": "search::ActivateTextMode"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -275,7 +281,10 @@
|
||||||
"alt-cmd-c": "search::ToggleCaseSensitive",
|
"alt-cmd-c": "search::ToggleCaseSensitive",
|
||||||
"alt-cmd-w": "search::ToggleWholeWord",
|
"alt-cmd-w": "search::ToggleWholeWord",
|
||||||
"alt-tab": "search::CycleMode",
|
"alt-tab": "search::CycleMode",
|
||||||
"alt-cmd-f": "project_search::ToggleFilters"
|
"alt-cmd-f": "project_search::ToggleFilters",
|
||||||
|
"alt-cmd-g": "search::ActivateRegexMode",
|
||||||
|
"alt-cmd-s": "search::ActivateSemanticMode",
|
||||||
|
"alt-cmd-x": "search::ActivateTextMode"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Bindings from VS Code
|
// Bindings from VS Code
|
||||||
|
|
|
@ -2,8 +2,9 @@ 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, ActivateSemanticMode, CycleMode, NextHistoryQuery, PreviousHistoryQuery,
|
ActivateRegexMode, ActivateSemanticMode, ActivateTextMode, CycleMode, NextHistoryQuery,
|
||||||
SearchOptions, SelectNextMatch, SelectPrevMatch, ToggleCaseSensitive, ToggleWholeWord,
|
PreviousHistoryQuery, SearchOptions, SelectNextMatch, SelectPrevMatch, ToggleCaseSensitive,
|
||||||
|
ToggleWholeWord,
|
||||||
};
|
};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
|
@ -63,6 +64,7 @@ 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);
|
||||||
|
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) {
|
if SemanticIndex::enabled(cx) {
|
||||||
|
@ -1341,6 +1343,19 @@ impl ProjectSearchBar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn activate_text_mode(pane: &mut Pane, _: &ActivateTextMode, 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::Text, cx)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
cx.propagate_action();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn activate_regex_mode(pane: &mut Pane, _: &ActivateRegexMode, cx: &mut ViewContext<Pane>) {
|
fn activate_regex_mode(pane: &mut Pane, _: &ActivateRegexMode, cx: &mut ViewContext<Pane>) {
|
||||||
if let Some(search_view) = pane
|
if let Some(search_view) = pane
|
||||||
.active_item()
|
.active_item()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue