Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Adjust copy/paste buffer only on the copy error action trigger
Kirill Bulatov31ff7d40ed67
diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rsindex e58aa1000d4..664d1d73806 100644--- a/crates/editor2/src/editor.rs+++ b/crates/editor2/src/editor.rs@@ -9739,12 +9739,8 @@ pub fn diagnostic_block_renderer(diagnostic: Diagnostic, is_valid: bool) -> Rend};highlighted_lines.push(line);}- let message = diagnostic.message;Arc::new(move |cx: &mut BlockContext| {- let message = message.clone();let copy_id: SharedString = format!("copy-{}", cx.block_id.clone()).to_string().into();- let write_to_clipboard = cx.write_to_clipboard(ClipboardItem::new(message.clone()));-// TODO: Nate: We should tint the background of the block with the severity color// We need to extend the theme before we can do thisv_stack()@@ -9754,7 +9750,6 @@ pub fn diagnostic_block_renderer(diagnostic: Diagnostic, is_valid: bool) -> Rend.bg(gpui::red()).children(highlighted_lines.iter().map(|(line, highlights)| {let group_id = cx.block_id.to_string();-h_stack().group(group_id.clone()).gap_2()@@ -9769,7 +9764,12 @@ pub fn diagnostic_block_renderer(diagnostic: Diagnostic, is_valid: bool) -> Rend.size(ButtonSize::Compact).style(ButtonStyle::Transparent).visible_on_hover(group_id)- .on_click(cx.listener(move |_, _, cx| write_to_clipboard))+ .on_click(cx.listener({+ let message = diagnostic.message.clone();+ move |_, _, cx| {+ cx.write_to_clipboard(ClipboardItem::new(message.clone()))+ }+ })).tooltip(|cx| Tooltip::text("Copy diagnostic message", cx)),),)