Update keybinds to use new names

Piotr Osiewicz created

Change summary

assets/keymaps/default.json         |  6 +++---
crates/search/src/project_search.rs | 18 ++++++++++++++++--
2 files changed, 19 insertions(+), 5 deletions(-)

Detailed changes

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"
     }
   },

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::<ToggleCaseSensitive>(SearchOptions::CASE_SENSITIVE, cx);
@@ -1296,6 +1297,19 @@ impl ProjectSearchBar {
         }
     }
 
+    fn activate_regex_mode(pane: &mut Pane, _: &ActivateRegexMode, 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::Regex, 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| {