diff --git a/crates/ui-egui/src/placing.rs b/crates/ui-egui/src/placing.rs index dee83f4967..ebdc1057cb 100644 --- a/crates/ui-egui/src/placing.rs +++ b/crates/ui-egui/src/placing.rs @@ -13,7 +13,7 @@ use std::collections::HashMap; use std::sync::mpsc::{Receiver, TryRecvError, channel}; -use craft::ui::dialog::DialogId; +use craft::ui::dialog::{DialogId, dialog_id}; use serde_json::{Value, json}; use vectorcraft_engine::cancel::{self, CancelToken}; use vectorcraft_engine::cmd::clipboard::{Clipboard, Flavour, ImageRead, read_image}; @@ -637,8 +637,11 @@ fn defer_question(app: &mut VectorcraftApp, chain: u64, insertion: &Insertion, s /// Runs a deferred paste whose question was answered, and releases it when the question closed /// without an answer. pub(crate) fn settle_swatch_paste(app: &mut VectorcraftApp) { - let Some(asked) = app.placing.swatch_paste.as_ref().map(|waiting| waiting.asked) else { return }; - let (question, taken) = take_question(app, asked); + let (question, taken) = match app.placing.swatch_paste.as_ref().map(|waiting| waiting.asked) { + Some(asked) => take_question(app, asked), + // A paste that ran at once (automation's) waits on nothing deferred: its Swatch Conflict answer runs it. + None => (Question::SwatchConflict, crate::dialogs::swatch_conflict::take(app, dialog_id(crate::dialogs::swatch_conflict::KIND))), + }; let answer = match taken { Taken::Open => return, Taken::Cancelled => return cancel_swatch_paste(app), diff --git a/crates/ui-egui/src/tests/clipboard.rs b/crates/ui-egui/src/tests/clipboard.rs index e56e2f3c36..f54e222b98 100644 --- a/crates/ui-egui/src/tests/clipboard.rs +++ b/crates/ui-egui/src/tests/clipboard.rs @@ -489,8 +489,9 @@ fn a_paste_event_waiting_on_a_refused_copy_pastes_that_copy() { crate::panels::character::intercept_text_command(&mut app, "edit.copy"); assert!(app.clipboard_publishing.is_pending()); - // The paste comes while the formats wait, and the write then fails with the clipboard open. - super::sysclip::lock(&board, true); + // The paste comes while the formats wait, and the write is then refused. The clipboard stays readable: with no + // change count, a refused copy is tracked by the clipboard's text (shell-w14), and one locked clipboard drops it. + super::sysclip::refuse_writes(&board, true); drop(hold); app.session.select_tool("selection", v).unwrap(); app.session.select_tool("type", v).unwrap();