diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index e8313ea91282f4f66b01557302e9de3c4f8e143c..b68dd89282383bb1082b11474ec034c0b970ee78 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -6,6 +6,7 @@ use std::mem; use std::ops::Range; use std::rc::Rc; use std::sync::Arc; +use std::time::Duration; use gpui::{ actions, point, quad, AnyElement, App, Bounds, ClipboardItem, CursorStyle, DispatchPhase, @@ -786,12 +787,28 @@ impl Element for MarkdownElement { ) .to_string(); move |_event, _window, cx| { + let id = id.clone(); markdown.update(cx, |this, cx| { this.copied_code_blocks.insert(id.clone()); cx.write_to_clipboard(ClipboardItem::new_string( code.clone(), )); + + cx.spawn(|this, cx| async move { + cx.background_executor() + .timer(Duration::from_secs(2)) + .await; + + cx.update(|cx| { + this.update(cx, |this, cx| { + this.copied_code_blocks.remove(&id); + cx.notify(); + }) + }) + .ok(); + }) + .detach(); }); } }),