Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

chat: add copy text entry to message menu (#8271)

Bennet Bo Fennerc90065e6ea55
diff --git a/crates/collab_ui/src/chat_panel.rs b/crates/collab_ui/src/chat_panel.rs
index 5c961e45350..9b7cec756dd 100644
--- a/crates/collab_ui/src/chat_panel.rs
+++ b/crates/collab_ui/src/chat_panel.rs
@@ -7,9 +7,9 @@ use collections::HashMap;
use db::kvp::KEY_VALUE_STORE;
use editor::Editor;
use gpui::{
- actions, div, list, prelude::*, px, Action, AppContext, AsyncWindowContext, CursorStyle,
- DismissEvent, ElementId, EventEmitter, FocusHandle, FocusableView, FontStyle, FontWeight,
- HighlightStyle, ListOffset, ListScrollEvent, ListState, Model, Render, StyledText,
+ actions, div, list, prelude::*, px, Action, AppContext, AsyncWindowContext, ClipboardItem,
+ CursorStyle, DismissEvent, ElementId, EventEmitter, FocusHandle, FocusableView, FontStyle,
+ FontWeight, HighlightStyle, ListOffset, ListScrollEvent, ListState, Model, Render, StyledText,
Subscription, Task, View, ViewContext, VisualContext, WeakView,
};
use language::LanguageRegistry;
@@ -629,6 +629,20 @@ impl ChatPanel {
})
}),
)
+ .entry(
+ "Copy message text",
+ None,
+ cx.handler_for(&this, move |this, cx| {
+ this.active_chat().map(|active_chat| {
+ if let Some(message) =
+ active_chat.read(cx).find_loaded_message(message_id)
+ {
+ let text = message.body.clone();
+ cx.write_to_clipboard(ClipboardItem::new(text))
+ }
+ });
+ }),
+ )
.when(can_delete_message, move |menu| {
menu.entry(
"Delete message",