Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Make channel notes view searchable and navigable via pane history
Max Brunsfelda95dcfa8bc74
diff --git a/crates/collab_ui/src/channel_view.rs b/crates/collab_ui/src/channel_view.rsindex 9c125117e10..bb1e840ffca 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<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 {diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rsindex 657aae5ff9d..477eab41ac9 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<Vector2F> {+ fn pixel_position_of_cursor(&self, _: &AppContext) -> Option<Vector2F> {self.pixel_position_of_newest_cursor}diff --git a/crates/vim/src/visual.rs b/crates/vim/src/visual.rsindex 1a11721a4e3..5e60ef59fc1 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 overthe 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 selectioncx.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 againcx.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! {"adiff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rsindex 4b5b7a79311..c218a852349 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<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)}}