mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
chat: closing reply preview with action (#7517)
This is a follow up to #7170. Closing the reply to preview overlay is now configurable with an action (keybinding set escape in the default keymap). https://github.com/zed-industries/zed/assets/53836821/d679e734-f90b-4490-8e79-7dfe5407988a Release Notes: - N/A
This commit is contained in:
commit
e6dad23154
@ -565,6 +565,12 @@
|
|||||||
"tab": "channel_modal::ToggleMode"
|
"tab": "channel_modal::ToggleMode"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"context": "ChatPanel > MessageEditor",
|
||||||
|
"bindings": {
|
||||||
|
"escape": "chat_panel::CloseReplyPreview"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"context": "Terminal",
|
"context": "Terminal",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
|
@ -70,7 +70,7 @@ struct SerializedChatPanel {
|
|||||||
width: Option<Pixels>,
|
width: Option<Pixels>,
|
||||||
}
|
}
|
||||||
|
|
||||||
actions!(chat_panel, [ToggleFocus]);
|
actions!(chat_panel, [ToggleFocus, CloseReplyPreview]);
|
||||||
|
|
||||||
impl ChatPanel {
|
impl ChatPanel {
|
||||||
pub fn new(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) -> View<Self> {
|
pub fn new(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) -> View<Self> {
|
||||||
@ -719,6 +719,11 @@ impl ChatPanel {
|
|||||||
Ok(())
|
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 {
|
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();
|
let reply_to_message_id = self.message_editor.read(cx).reply_to_message_id();
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
|
.key_context("ChatPanel")
|
||||||
.track_focus(&self.focus_handle)
|
.track_focus(&self.focus_handle)
|
||||||
.full()
|
.full()
|
||||||
.on_action(cx.listener(Self::send))
|
.on_action(cx.listener(Self::send))
|
||||||
@ -810,10 +816,15 @@ impl Render for ChatPanel {
|
|||||||
.child(
|
.child(
|
||||||
IconButton::new("close-reply-preview", IconName::Close)
|
IconButton::new("close-reply-preview", IconName::Close)
|
||||||
.shape(ui::IconButtonShape::Square)
|
.shape(ui::IconButtonShape::Square)
|
||||||
.on_click(cx.listener(move |this, _, cx| {
|
.tooltip(|cx| {
|
||||||
this.message_editor.update(cx, |editor, _| {
|
Tooltip::for_action(
|
||||||
editor.clear_reply_to_message_id()
|
"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(
|
.children(
|
||||||
Some(
|
Some(
|
||||||
h_flex()
|
h_flex()
|
||||||
|
.key_context("MessageEditor")
|
||||||
|
.on_action(cx.listener(ChatPanel::close_reply_preview))
|
||||||
.when(
|
.when(
|
||||||
!self.is_scrolled_to_bottom && reply_to_message_id.is_none(),
|
!self.is_scrolled_to_bottom && reply_to_message_id.is_none(),
|
||||||
|el| el.border_t_1().border_color(cx.theme().colors().border),
|
|el| el.border_t_1().border_color(cx.theme().colors().border),
|
||||||
|
Loading…
Reference in New Issue
Block a user