From 0ca29e56c26152c84d2efe16b8c8c6ae7fc03825 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:33:51 +0200 Subject: [PATCH] Update keybinds to use new names --- assets/keymaps/default.json | 6 +++--- crates/search/src/project_search.rs | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index 2f13ee6d03..97dad7a831 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -238,7 +238,7 @@ "context": "ProjectSearchBar", "bindings": { "escape": "project_search::ToggleFocus", - "alt-tab": "project_search::CycleMode" + "alt-tab": "search::CycleMode" } }, { @@ -252,7 +252,7 @@ "context": "ProjectSearchView", "bindings": { "escape": "project_search::ToggleFocus", - "alt-tab": "project_search::CycleMode" + "alt-tab": "search::CycleMode" } }, { @@ -264,7 +264,7 @@ "alt-enter": "search::SelectAllMatches", "alt-cmd-c": "search::ToggleCaseSensitive", "alt-cmd-w": "search::ToggleWholeWord", - "alt-cmd-r": "search::ToggleRegex", + "alt-cmd-r": "search::ActivateRegexMode", "alt-cmd-f": "project_search::ToggleFilters" } }, diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index fa2630f969..5fed36994a 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -2,8 +2,8 @@ use crate::{ elements::ButtonSide, history::SearchHistory, mode::{SearchMode, Side}, - CycleMode, NextHistoryQuery, PreviousHistoryQuery, SearchOptions, SelectNextMatch, - SelectPrevMatch, ToggleCaseSensitive, ToggleWholeWord, + ActivateRegexMode, CycleMode, NextHistoryQuery, PreviousHistoryQuery, SearchOptions, + SelectNextMatch, SelectPrevMatch, ToggleCaseSensitive, ToggleWholeWord, }; use anyhow::{Context, Result}; use collections::HashMap; @@ -66,6 +66,7 @@ pub fn init(cx: &mut AppContext) { cx.add_action(ProjectSearchBar::cycle_mode); cx.add_action(ProjectSearchBar::next_history_query); cx.add_action(ProjectSearchBar::previous_history_query); + cx.add_action(ProjectSearchBar::activate_regex_mode); cx.capture_action(ProjectSearchBar::tab); cx.capture_action(ProjectSearchBar::tab_previous); add_toggle_option_action::(SearchOptions::CASE_SENSITIVE, cx); @@ -1296,6 +1297,19 @@ impl ProjectSearchBar { } } + fn activate_regex_mode(pane: &mut Pane, _: &ActivateRegexMode, cx: &mut ViewContext) { + if let Some(search_view) = pane + .active_item() + .and_then(|item| item.downcast::()) + { + search_view.update(cx, |view, cx| { + view.activate_search_mode(SearchMode::Regex, cx) + }); + } else { + cx.propagate_action(); + } + } + fn toggle_filters(&mut self, cx: &mut ViewContext) -> bool { if let Some(search_view) = self.active_project_search.as_ref() { search_view.update(cx, |search_view, cx| {