Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
allow closing reply to preview with action
Bennet Bo Fenneref8cab65b039
diff --git a/assets/keymaps/default.json b/assets/keymaps/default.jsonindex 06358dab225..6e2b96b3387 100644--- a/assets/keymaps/default.json+++ b/assets/keymaps/default.json@@ -565,6 +565,12 @@"tab": "channel_modal::ToggleMode"}},+ {+ "context": "ChatPanel > MessageEditor",+ "bindings": {+ "escape": "chat_panel::CloseReplyPreview"+ }+ },{"context": "Terminal","bindings": {diff --git a/crates/collab_ui/src/chat_panel.rs b/crates/collab_ui/src/chat_panel.rsindex 9a751335fad..999f02f2e07 100644--- a/crates/collab_ui/src/chat_panel.rs+++ b/crates/collab_ui/src/chat_panel.rs@@ -70,7 +70,7 @@ struct SerializedChatPanel {width: Option<Pixels>,}-actions!(chat_panel, [ToggleFocus]);+actions!(chat_panel, [ToggleFocus, CloseReplyPreview]);impl ChatPanel {pub fn new(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) -> View<Self> {@@ -719,6 +719,11 @@ impl ChatPanel {Ok(())})}++ fn close_reply_preview(&mut self, _: &CloseReplyPreview, cx: &mut ViewContext<Self>) {+ self.message_editor+ .update(cx, |editor, _| editor.clear_reply_to_message_id());+ }}impl Render for ChatPanel {@@ -726,6 +731,7 @@ impl Render for ChatPanel {let reply_to_message_id = self.message_editor.read(cx).reply_to_message_id();v_flex()+ .key_context("ChatPanel").track_focus(&self.focus_handle).full().on_action(cx.listener(Self::send))@@ -810,10 +816,15 @@ impl Render for ChatPanel {.child(IconButton::new("close-reply-preview", IconName::Close).shape(ui::IconButtonShape::Square)- .on_click(cx.listener(move |this, _, cx| {- this.message_editor.update(cx, |editor, _| {- editor.clear_reply_to_message_id()- });+ .tooltip(|cx| {+ Tooltip::for_action(+ "Close reply preview",+ &CloseReplyPreview,+ cx,+ )+ })+ .on_click(cx.listener(move |_, _, cx| {+ cx.dispatch_action(CloseReplyPreview.boxed_clone())})),),)@@ -822,6 +833,8 @@ impl Render for ChatPanel {.children(Some(h_flex()+ .key_context("MessageEditor")+ .on_action(cx.listener(ChatPanel::close_reply_preview)).when(!self.is_scrolled_to_bottom && reply_to_message_id.is_none(),|el| el.border_t_1().border_color(cx.theme().colors().border),