mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 02:37:21 +00:00
Reraise editor events in Project Search and activate workspace item from them
This commit is contained in:
parent
206b0f0f8c
commit
3c116e32cb
1 changed files with 16 additions and 0 deletions
|
@ -139,6 +139,7 @@ impl ProjectSearch {
|
|||
|
||||
pub enum ViewEvent {
|
||||
UpdateTab,
|
||||
EditorEvent(editor::Event),
|
||||
}
|
||||
|
||||
impl Entity for ProjectSearchView {
|
||||
|
@ -307,6 +308,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)
|
||||
}
|
||||
|
@ -341,6 +350,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);
|
||||
|
@ -353,6 +367,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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue