diff --git a/crates/collab_ui/src/channel_view.rs b/crates/collab_ui/src/channel_view.rs index 9c125117e1..bb1e840ffc 100644 --- a/crates/collab_ui/src/channel_view.rs +++ b/crates/collab_ui/src/channel_view.rs @@ -10,13 +10,17 @@ use editor::Editor; use gpui::{ actions, elements::{ChildView, Label}, + geometry::vector::Vector2F, AnyElement, AnyViewHandle, AppContext, Element, Entity, ModelHandle, Subscription, Task, View, ViewContext, ViewHandle, }; use project::Project; +use std::any::Any; use workspace::{ item::{FollowableItem, Item, ItemHandle}, - register_followable_item, Pane, ViewId, Workspace, WorkspaceId, + register_followable_item, + searchable::SearchableItemHandle, + ItemNavHistory, Pane, ViewId, Workspace, WorkspaceId, }; actions!(channel_view, [Deploy]); @@ -207,6 +211,37 @@ impl Item for ChannelView { cx, )) } + + fn is_singleton(&self, _cx: &AppContext) -> bool { + true + } + + fn navigate(&mut self, data: Box, cx: &mut ViewContext) -> bool { + self.editor + .update(cx, |editor, cx| editor.navigate(data, cx)) + } + + fn deactivated(&mut self, cx: &mut ViewContext) { + self.editor + .update(cx, |editor, cx| Item::deactivated(editor, cx)) + } + + fn set_nav_history(&mut self, history: ItemNavHistory, cx: &mut ViewContext) { + self.editor + .update(cx, |editor, cx| Item::set_nav_history(editor, history, cx)) + } + + fn as_searchable(&self, _: &ViewHandle) -> Option> { + Some(Box::new(self.editor.clone())) + } + + fn show_toolbar(&self) -> bool { + true + } + + fn pixel_position_of_cursor(&self, cx: &AppContext) -> Option { + self.editor.read(cx).pixel_position_of_cursor(cx) + } } impl FollowableItem for ChannelView { diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 657aae5ff9..477eab41ac 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -754,7 +754,7 @@ impl Item for Editor { Some(Box::new(handle.clone())) } - fn pixel_position_of_cursor(&self) -> Option { + fn pixel_position_of_cursor(&self, _: &AppContext) -> Option { self.pixel_position_of_newest_cursor } diff --git a/crates/vim/src/visual.rs b/crates/vim/src/visual.rs index 1a11721a4e..5e60ef59fc 100644 --- a/crates/vim/src/visual.rs +++ b/crates/vim/src/visual.rs @@ -391,7 +391,7 @@ mod test { the lazy dog" }) .await; - let cursor = cx.update_editor(|editor, _| editor.pixel_position_of_cursor()); + let cursor = cx.update_editor(|editor, cx| editor.pixel_position_of_cursor(cx)); // entering visual mode should select the character // under cursor @@ -400,7 +400,7 @@ mod test { fox jumps over the lazy dog"}) .await; - cx.update_editor(|editor, _| assert_eq!(cursor, editor.pixel_position_of_cursor())); + cx.update_editor(|editor, cx| assert_eq!(cursor, editor.pixel_position_of_cursor(cx))); // forwards motions should extend the selection cx.simulate_shared_keystrokes(["w", "j"]).await; @@ -430,7 +430,7 @@ mod test { b "}) .await; - let cursor = cx.update_editor(|editor, _| editor.pixel_position_of_cursor()); + let cursor = cx.update_editor(|editor, cx| editor.pixel_position_of_cursor(cx)); cx.simulate_shared_keystrokes(["v"]).await; cx.assert_shared_state(indoc! {" a @@ -438,7 +438,7 @@ mod test { ˇ»b "}) .await; - cx.update_editor(|editor, _| assert_eq!(cursor, editor.pixel_position_of_cursor())); + cx.update_editor(|editor, cx| assert_eq!(cursor, editor.pixel_position_of_cursor(cx))); // toggles off again cx.simulate_shared_keystrokes(["v"]).await; @@ -510,7 +510,7 @@ mod test { b ˇ"}) .await; - let cursor = cx.update_editor(|editor, _| editor.pixel_position_of_cursor()); + let cursor = cx.update_editor(|editor, cx| editor.pixel_position_of_cursor(cx)); cx.simulate_shared_keystrokes(["shift-v"]).await; cx.assert_shared_state(indoc! {" a @@ -518,7 +518,7 @@ mod test { ˇ"}) .await; assert_eq!(cx.mode(), cx.neovim_mode().await); - cx.update_editor(|editor, _| assert_eq!(cursor, editor.pixel_position_of_cursor())); + cx.update_editor(|editor, cx| assert_eq!(cursor, editor.pixel_position_of_cursor(cx))); cx.simulate_shared_keystrokes(["x"]).await; cx.assert_shared_state(indoc! {" a diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index 4b5b7a7931..c218a85234 100644 --- a/crates/workspace/src/item.rs +++ b/crates/workspace/src/item.rs @@ -158,9 +158,7 @@ pub trait Item: View { fn should_update_tab_on_event(_: &Self::Event) -> bool { false } - fn is_edit_event(_: &Self::Event) -> bool { - false - } + fn act_as_type<'a>( &'a self, type_id: TypeId, @@ -205,7 +203,7 @@ pub trait Item: View { fn show_toolbar(&self) -> bool { true } - fn pixel_position_of_cursor(&self) -> Option { + fn pixel_position_of_cursor(&self, _: &AppContext) -> Option { None } } @@ -623,7 +621,7 @@ impl ItemHandle for ViewHandle { } fn pixel_position_of_cursor(&self, cx: &AppContext) -> Option { - self.read(cx).pixel_position_of_cursor() + self.read(cx).pixel_position_of_cursor(cx) } }