Toggle project search options via the keyboard
This commit is contained in:
parent
d0d6c27ae9
commit
29e57c8e3c
1 changed files with 18 additions and 6 deletions
|
@ -35,10 +35,23 @@ pub fn init(cx: &mut MutableAppContext) {
|
||||||
cx.add_action(ProjectSearchView::deploy);
|
cx.add_action(ProjectSearchView::deploy);
|
||||||
cx.add_action(ProjectSearchBar::search);
|
cx.add_action(ProjectSearchBar::search);
|
||||||
cx.add_action(ProjectSearchBar::search_in_new);
|
cx.add_action(ProjectSearchBar::search_in_new);
|
||||||
cx.add_action(ProjectSearchBar::toggle_search_option);
|
|
||||||
cx.add_action(ProjectSearchBar::select_next_match);
|
cx.add_action(ProjectSearchBar::select_next_match);
|
||||||
cx.add_action(ProjectSearchBar::select_prev_match);
|
cx.add_action(ProjectSearchBar::select_prev_match);
|
||||||
cx.add_action(ProjectSearchBar::toggle_focus);
|
cx.add_action(ProjectSearchBar::toggle_focus);
|
||||||
|
cx.add_action(
|
||||||
|
|pane: &mut Pane,
|
||||||
|
ToggleSearchOption { option }: &ToggleSearchOption,
|
||||||
|
cx: &mut ViewContext<Pane>| {
|
||||||
|
if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::<ProjectSearchBar>() {
|
||||||
|
if search_bar.update(cx, |search_bar, cx| {
|
||||||
|
search_bar.toggle_search_option(*option, cx)
|
||||||
|
}) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cx.propagate_action();
|
||||||
|
},
|
||||||
|
);
|
||||||
cx.capture_action(ProjectSearchBar::tab);
|
cx.capture_action(ProjectSearchBar::tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,11 +666,7 @@ impl ProjectSearchBar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_search_option(
|
fn toggle_search_option(&mut self, option: SearchOption, cx: &mut ViewContext<Self>) -> bool {
|
||||||
&mut self,
|
|
||||||
ToggleSearchOption { option }: &ToggleSearchOption,
|
|
||||||
cx: &mut ViewContext<Self>,
|
|
||||||
) {
|
|
||||||
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| {
|
||||||
let value = match option {
|
let value = match option {
|
||||||
|
@ -669,6 +678,9 @@ impl ProjectSearchBar {
|
||||||
search_view.search(cx);
|
search_view.search(cx);
|
||||||
});
|
});
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue