Run a paste whose Swatch Conflict question was answered when no deferred paste waits on it; the refused-copy paste test refuses the write with the clipboard readable, as the content rule tracks it

This commit is contained in:
bflatastic
2026-11-23 01:55:50 +07:00
parent 700f8c7899
commit 81d3fabb1a
2 changed files with 9 additions and 5 deletions
+6 -3
View File
@@ -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),
+3 -2
View File
@@ -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();