@@ -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<dyn Any>, cx: &mut ViewContext<Self>) -> bool {
+ self.editor
+ .update(cx, |editor, cx| editor.navigate(data, cx))
+ }
+
+ fn deactivated(&mut self, cx: &mut ViewContext<Self>) {
+ self.editor
+ .update(cx, |editor, cx| Item::deactivated(editor, cx))
+ }
+
+ fn set_nav_history(&mut self, history: ItemNavHistory, cx: &mut ViewContext<Self>) {
+ self.editor
+ .update(cx, |editor, cx| Item::set_nav_history(editor, history, cx))
+ }
+
+ fn as_searchable(&self, _: &ViewHandle<Self>) -> Option<Box<dyn SearchableItemHandle>> {
+ Some(Box::new(self.editor.clone()))
+ }
+
+ fn show_toolbar(&self) -> bool {
+ true
+ }
+
+ fn pixel_position_of_cursor(&self, cx: &AppContext) -> Option<Vector2F> {
+ self.editor.read(cx).pixel_position_of_cursor(cx)
+ }
}
impl FollowableItem for ChannelView {
@@ -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
@@ -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<Vector2F> {
+ fn pixel_position_of_cursor(&self, _: &AppContext) -> Option<Vector2F> {
None
}
}
@@ -623,7 +621,7 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
}
fn pixel_position_of_cursor(&self, cx: &AppContext) -> Option<Vector2F> {
- self.read(cx).pixel_position_of_cursor()
+ self.read(cx).pixel_position_of_cursor(cx)
}
}