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.

Add a `Copy` button for `About Zed` (#33197)

张小白af8f26dd34d1
diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs
index 1723d3ff69c..44c88eb4694 100644
--- a/crates/zed/src/zed.rs
+++ b/crates/zed/src/zed.rs
@@ -944,12 +944,23 @@ fn about(
let message = format!("{release_channel} {version} {debug}");
let detail = AppCommitSha::try_global(cx).map(|sha| sha.full());
- let prompt = window.prompt(PromptLevel::Info, &message, detail.as_deref(), &["OK"], cx);
- cx.foreground_executor()
- .spawn(async {
- prompt.await.ok();
- })
- .detach();
+ let prompt = window.prompt(
+ PromptLevel::Info,
+ &message,
+ detail.as_deref(),
+ &["Copy", "OK"],
+ cx,
+ );
+ cx.spawn(async move |_, cx| {
+ if let Ok(0) = prompt.await {
+ let content = format!("{}\n{}", message, detail.as_deref().unwrap_or(""));
+ cx.update(|cx| {
+ cx.write_to_clipboard(gpui::ClipboardItem::new_string(content));
+ })
+ .ok();
+ }
+ })
+ .detach();
}
fn test_panic(_: &TestPanic, _: &mut App) {