Add cursor position to feedback editor

Joseph Lyons , Mikayla Maki , and Max Brunsfeld created

Co-Authored-By: Mikayla Maki <mikayla.c.maki@gmail.com>
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>

Change summary

crates/editor/src/items.rs             |  2 +-
crates/feedback/src/feedback_editor.rs | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)

Detailed changes

crates/editor/src/items.rs 🔗

@@ -1094,7 +1094,7 @@ impl StatusItemView for CursorPosition {
         active_pane_item: Option<&dyn ItemHandle>,
         cx: &mut ViewContext<Self>,
     ) {
-        if let Some(editor) = active_pane_item.and_then(|item| item.downcast::<Editor>()) {
+        if let Some(editor) = active_pane_item.and_then(|item| item.act_as::<Editor>(cx)) {
             self._observe_active_editor = Some(cx.observe(&editor, Self::update_position));
             self.update_position(editor, cx);
         } else {

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<Self>) -> Option<Box<dyn SearchableItemHandle>> {
         Some(Box::new(handle.clone()))
     }
+
+    fn act_as_type(
+        &self,
+        type_id: TypeId,
+        self_handle: &ViewHandle<Self>,
+        _: &AppContext,
+    ) -> Option<AnyViewHandle> {
+        if type_id == TypeId::of::<Self>() {
+            Some(self_handle.into())
+        } else if type_id == TypeId::of::<Editor>() {
+            Some((&self.editor).into())
+        } else {
+            None
+        }
+    }
 }
 
 impl SearchableItem for FeedbackEditor {