mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 14:17:02 +00:00
Merge pull request #791 from zed-industries/project-search-focus-fix
Properly activate project search item on mouse click
This commit is contained in:
commit
2807d85a60
1 changed files with 16 additions and 0 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue