diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index f96e3c84d1..e2f5cd4261 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -136,6 +136,7 @@ impl ProjectSearch { pub enum ViewEvent { UpdateTab, + EditorEvent(editor::Event), } impl Entity for ProjectSearchView { @@ -304,6 +305,14 @@ impl Item for ProjectSearchView { .update(cx, |editor, cx| editor.navigate(data, cx)) } + fn should_activate_item_on_event(event: &Self::Event) -> bool { + if let ViewEvent::EditorEvent(editor_event) = event { + Editor::should_activate_item_on_event(editor_event) + } else { + false + } + } + fn should_update_tab_on_event(event: &ViewEvent) -> bool { matches!(event, ViewEvent::UpdateTab) } @@ -338,6 +347,11 @@ impl ProjectSearchView { editor.set_text(query_text, cx); editor }); + // Subcribe to query_editor in order to reraise editor events for workspace item activation purposes + cx.subscribe(&query_editor, |_, _, event, cx| { + cx.emit(ViewEvent::EditorEvent(event.clone())) + }) + .detach(); let results_editor = cx.add_view(|cx| { let mut editor = Editor::for_multibuffer(excerpts, Some(project), cx); @@ -350,6 +364,8 @@ impl ProjectSearchView { if matches!(event, editor::Event::SelectionsChanged { .. }) { this.update_match_index(cx); } + // Reraise editor events for workspace item activation purposes + cx.emit(ViewEvent::EditorEvent(event.clone())); }) .detach();