From f68f9f37ab61cdccdc93be044e0c375a63cec50a Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Wed, 25 Jan 2023 14:20:23 -0500 Subject: [PATCH] Add cursor position to feedback editor Co-Authored-By: Mikayla Maki Co-Authored-By: Max Brunsfeld --- crates/editor/src/items.rs | 2 +- crates/feedback/src/feedback_editor.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 7e7f44e514..501306aa19 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -1094,7 +1094,7 @@ impl StatusItemView for CursorPosition { active_pane_item: Option<&dyn ItemHandle>, cx: &mut ViewContext, ) { - if let Some(editor) = active_pane_item.and_then(|item| item.downcast::()) { + if let Some(editor) = active_pane_item.and_then(|item| item.act_as::(cx)) { self._observe_active_editor = Some(cx.observe(&editor, Self::update_position)); self.update_position(editor, cx); } else { diff --git a/crates/feedback/src/feedback_editor.rs b/crates/feedback/src/feedback_editor.rs index 3a6bc744f2..a3318d3efe 100644 --- a/crates/feedback/src/feedback_editor.rs +++ b/crates/feedback/src/feedback_editor.rs @@ -1,4 +1,5 @@ use std::{ + any::TypeId, ops::{Range, RangeInclusive}, sync::Arc, }; @@ -358,6 +359,21 @@ impl Item for FeedbackEditor { fn as_searchable(&self, handle: &ViewHandle) -> Option> { Some(Box::new(handle.clone())) } + + fn act_as_type( + &self, + type_id: TypeId, + self_handle: &ViewHandle, + _: &AppContext, + ) -> Option { + if type_id == TypeId::of::() { + Some(self_handle.into()) + } else if type_id == TypeId::of::() { + Some((&self.editor).into()) + } else { + None + } + } } impl SearchableItem for FeedbackEditor {