ElyMark: R4.10 round 3 fixes; R4.10 marked [~]

The copy guard also compares the clipboard's HTML, which gpui omits,
so a later rich copy with the same plain text is not overwritten.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-14 22:16:08 -04:00
1 parent 2c374b23ed
commit 65514599fe
6 files changed
+49 -4

No files matched your search

+11 -2
View File
@@ -64,7 +64,7 @@ impl Desk {
let Some((markdown, beside)) = self.copied_text(cx) else {
return;
};
let before = cx.read_from_clipboard();
let before = witness(cx);
self.copying = Some(cx.spawn(async move |desk, cx| {
let converted = cx
.background_executor()
@@ -73,7 +73,7 @@ impl Desk {
let landed = desk.update(cx, |desk, cx| {
desk.copying = None;
// A later copy, here or elsewhere, wins.
if cx.read_from_clipboard() != before {
if witness(cx) != before {
return log::info!("mark: the clipboard changed first; a copy is dropped");
}
desk.copied(converted, cx);
@@ -108,6 +108,15 @@ impl Desk {
}
}
/// What the clipboard holds, its HTML included.
fn witness(cx: &mut Context<Desk>) -> (Option<ClipboardItem>, Result<Option<String>, String>) {
let html = clipboard::html().map_err(|error| {
log::warn!("mark: the clipboard's HTML did not read: {error:#}");
format!("{error:#}")
});
(cx.read_from_clipboard(), html)
}
/// The copy as `kind`, converted off the window thread.
fn convert(kind: As, markdown: String, beside: Option<PathBuf>) -> std::io::Result<Copied> {
let beside = beside.as_deref();