Add Editor::Tab and CycleMode actions

This commit is contained in:
Piotr Osiewicz 2023-12-11 16:39:17 +01:00
parent 9f1e7a1e21
commit 40c1ef88e2

View file

@ -1287,18 +1287,15 @@ impl ProjectSearchBar {
subscription: Default::default(), subscription: Default::default(),
} }
} }
fn cycle_mode(workspace: &mut Workspace, _: &CycleMode, cx: &mut ViewContext<Workspace>) { fn cycle_mode(&self, _: &CycleMode, cx: &mut ViewContext<Self>) {
if let Some(search_view) = workspace if let Some(view) = self.active_project_search.as_ref() {
.active_item(cx) view.update(cx, |this, cx| {
.and_then(|item| item.downcast::<ProjectSearchView>()) // todo: po: 2nd argument of `next_mode` should be `SemanticIndex::enabled(cx))`, but we need to flesh out port of semantic_index first.
{ let new_mode = crate::mode::next_mode(&this.current_mode, false);
search_view.update(cx, |this, cx| {
let new_mode =
crate::mode::next_mode(&this.current_mode, SemanticIndex::enabled(cx));
this.activate_search_mode(new_mode, cx); this.activate_search_mode(new_mode, cx);
let editor_handle = this.query_editor.focus_handle(cx); let editor_handle = this.query_editor.focus_handle(cx);
cx.focus(&editor_handle); cx.focus(&editor_handle);
}) });
} }
} }
fn confirm(&mut self, _: &Confirm, cx: &mut ViewContext<Self>) { fn confirm(&mut self, _: &Confirm, cx: &mut ViewContext<Self>) {
@ -1800,6 +1797,15 @@ impl Render for ProjectSearchBar {
}) })
} }
})) }))
.on_action(cx.listener(|this, action, cx| {
this.tab(action, cx);
}))
.on_action(cx.listener(|this, action, cx| {
this.tab_previous(action, cx);
}))
.on_action(cx.listener(|this, action, cx| {
this.cycle_mode(action, cx);
}))
.child(query_column) .child(query_column)
.child(mode_column) .child(mode_column)
.child(replace_column) .child(replace_column)