From af8f26dd34d1858dfc6201418cec81011b45f044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B0=8F=E7=99=BD?= <364772080@qq.com> Date: Sun, 22 Jun 2025 19:12:12 +0800 Subject: [PATCH] Add a `Copy` button for `About Zed` (#33197) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #33160 Since `TaskDialog` doesn’t allow users to copy its contents directly, VSCode added a `Copy` button so users can easily copy the message. https://github.com/user-attachments/assets/04090753-226f-44d9-992c-8cc8cb8d7ecb Release Notes: - N/A --- crates/zed/src/zed.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 1723d3ff69..44c88eb469 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) {