Merge pull request #8486 from dotCooCoo/fix/place-into-its-layer

Place: a file read in the background goes into the layer it was placed in
This commit is contained in:
BFlat
2026-11-18 13:14:52 +07:00
committed by GitHub
2 changed files with 348 additions and 12 deletions
+60 -12
View File
@@ -21,10 +21,11 @@ use vectorcraft_engine::file_access::ScopeHandle;
use crate::VectorcraftApp;
/// What was read: one file to place, the files to load the place cursor with (and whether they ask
/// for their import options when placed), or a bitmap to paste.
/// What was read: one file to place (and where new art went when it was placed), the files to load
/// the place cursor with (and whether they ask for their import options when placed), or a bitmap
/// to paste.
enum Read {
Place(Box<PlaceRead>),
Place(Box<PlaceRead>, Insertion),
Queue(QueueRead, bool),
Paste(Box<Paste>),
}
@@ -56,7 +57,8 @@ struct Paste {
}
/// Where new art goes in the active document: the current layer, the isolated group or object, and
/// the drawing mode with the object Draw Inside draws into.
/// the drawing mode with the object Draw Inside draws into. A paste and a placed file read off the
/// UI thread keep the one from when they were given.
#[derive(Clone, PartialEq)]
struct Insertion {
layer: Option<vectorcraft_doc::NodeId>,
@@ -81,9 +83,34 @@ impl Insertion {
Some(Self { layer, isolation, draw_mode, draw_inside })
}
/// Whether new art can still go where `self` says in `app`'s active document: the isolated group
/// or object when it names one, else the object Draw Inside draws into when it names one and
/// `draws_inside` (a paste draws inside it, a placed file does not), else its layer, which must
/// still be a layer, is still there, shown and unlocked. A paste or a placed file whose layer or
/// group was deleted, hidden or locked meanwhile goes where new art goes now.
fn usable(&self, app: &VectorcraftApp, draws_inside: bool) -> bool {
app.session.doc().is_ok_and(|st| {
let inside = self.draw_inside.filter(|_| draws_inside && self.draw_mode == vectorcraft_engine::DrawMode::Inside);
match (self.isolation, inside, self.layer) {
(Some(target), ..) | (None, Some(target), _) => st.doc.is_editable(target),
(None, None, Some(l)) => st.doc.node(l).is_some_and(|n| n.is_layer()) && st.doc.is_editable(l),
(None, None, None) => true,
}
})
}
/// `self` when new art can still go there ([`Self::usable`]), else `now`: where new art went
/// before the paste or the place selected anything again.
fn or_now(self, now: Option<&Self>, app: &VectorcraftApp, draws_inside: bool) -> Self {
match now {
Some(now) if !self.usable(app, draws_inside) => now.clone(),
_ => self,
}
}
/// Put back each part of `self` (where new art went before [`Self::set`] set `started`) that
/// differs from `started`, what the user changed meanwhile; a part the paste itself changed
/// stays as the paste left it.
/// differs from `started`, what the user changed meanwhile; a part the paste or the place
/// itself changed stays as it left it.
fn restore_changed(self, started: &Self, app: &mut VectorcraftApp) {
if let Ok(st) = app.session.doc_mut() {
if self.layer != started.layer {
@@ -224,7 +251,9 @@ pub fn start(app: &mut VectorcraftApp, p: &Value, dropped: bool) -> Result<Value
crate::canvas::apply_requests(app, r);
let job = app.session.prepare_place(p).map_err(|e| e.to_string())?;
let name = job.name();
let started = spawn(app, name.clone(), name, dropped, move || job.read().map(|r| Read::Place(Box::new(r))).map_err(|e| e.to_string()))?;
let insertion = Insertion::of(app).ok_or("no document")?;
let started =
spawn(app, name.clone(), name, dropped, move || job.read().map(|r| Read::Place(Box::new(r), insertion)).map_err(|e| e.to_string()))?;
started.map_or_else(
|| {
let r = app.session.execute("file.place", p).map_err(|e| e.to_string());
@@ -486,7 +515,19 @@ fn finish(app: &mut VectorcraftApp, p: &Pending, r: Result<Read, String>) {
}
app.session.set_active(i);
let r = match r {
Ok(Read::Place(read)) => app.session.place_read(*read).map(|_| ()).map_err(|e| e.to_string()),
Ok(Read::Place(read, insertion)) => {
// The file goes where new art went when it was placed (the current layer, the isolated
// group), as a paste does, and what the user changed meanwhile is kept. Where new art
// goes now is taken before Replace selects the object it swaps again.
let current = Insertion::of(app);
let insertion = insertion.or_now(current.as_ref(), app, false);
insertion.clone().set(app);
let r = app.session.place_read(*read).map(|_| ()).map_err(|e| e.to_string());
if let Some(current) = current {
current.restore_changed(&insertion, app);
}
r
}
Ok(Read::Queue(read, asks)) => {
app.session.place_queue_read(read).map(|r| crate::place::show_thumbnails(app, &r, asks)).map_err(|e| e.to_string())
}
@@ -540,7 +581,8 @@ fn finish_paste(app: &mut VectorcraftApp, paste: Paste) {
// The paste goes where new art went when it started (the current layer, the isolated
// group, the object Draw Inside draws into), and what the user changed meanwhile is
// kept.
paste.insertion.clone().set(app);
let insertion = paste.insertion.or_now(current.as_ref(), app, pastes_inside(&paste.id));
insertion.clone().set(app);
let requested_selection = app.session.doc().map(|st| st.selection.objects.clone()).unwrap_or_default();
app.placing.adopted = true;
// `run` shows an error in the status bar.
@@ -552,7 +594,7 @@ fn finish_paste(app: &mut VectorcraftApp, paste: Paste) {
if let Ok(st) = app.session.doc() {
app.placing.swatch_paste = Some(PendingSwatch {
clipboard: app.session.clipboard.clone(),
insertion: paste.insertion.clone(),
insertion: insertion.clone(),
selection: requested_selection,
doc: st.uid,
reverts: st.reverts,
@@ -562,7 +604,7 @@ fn finish_paste(app: &mut VectorcraftApp, paste: Paste) {
}
}
if let Some(current) = current {
current.restore_changed(&paste.insertion, app);
current.restore_changed(&insertion, app);
}
app.session.doc().ok().map(|st| st.selection.objects.clone())
}
@@ -613,6 +655,12 @@ pub(crate) fn settle_swatch_paste(app: &mut VectorcraftApp) {
}
}
/// Does the paste command `id` paste inside the object Draw Inside draws into? Paste in Front and
/// Paste in Back keep their own places.
fn pastes_inside(id: &str) -> bool {
!matches!(id, "edit.pasteInFront" | "edit.pasteInBack")
}
/// Run the command confirmed by the deferred paste's Swatch Conflict dialog.
pub(crate) fn confirm_swatch_paste(app: &mut VectorcraftApp, id: &str, params: Value, token: Option<u64>) -> Result<Value, String> {
if !app.placing.swatch_paste.as_ref().is_some_and(|waiting| Some(waiting.chain) == token) {
@@ -643,7 +691,7 @@ pub(crate) fn confirm_swatch_paste(app: &mut VectorcraftApp, id: &str, params: V
if selected != now.iter().map(|id| id.0).collect::<Vec<_>>() {
let _ = app.session.execute("select.set", &json!({"ids": selected}));
}
let insertion = waiting.insertion.clone();
let insertion = waiting.insertion.clone().or_now(changed.as_ref(), app, pastes_inside(id));
insertion.clone().set(app);
app.placing.adopted = true;
let result = app.run(id, params);
+288
View File
@@ -661,6 +661,134 @@ fn a_deferred_swatch_paste_uses_its_original_layer() {
assert_eq!(st.current_layer(), Some(second));
}
/// A bitmap pasted from another app while a group is isolated goes into that group when the
/// isolation ends and the current layer, which does not hold the group, is locked while the bitmap
/// is decoded.
#[test]
fn a_bitmap_pasted_into_an_isolated_group_stays_there_when_another_layer_is_locked() {
let (mut app, _) = pasting_app(true, Some(Flavour { mime: PNG, data: picture(Png, 60, 40) }), None, true);
let first = app.session.doc().unwrap().doc.layers[0].id;
app.run("layer.new", json!({})).unwrap();
let squares: Vec<Value> =
(0..2).map(|i| app.run("shape.rectangle", json!({"x": 10 + 30 * i, "y": 10, "width": 20, "height": 20})).unwrap()["id"].clone()).collect();
app.run("select.set", json!({"ids": squares})).unwrap();
let group = NodeId(app.run("object.group", json!({})).unwrap()["id"].as_u64().unwrap());
app.run("select.none", json!({})).unwrap();
app.run("layer.setCurrent", json!({"id": first.0})).unwrap();
app.run("object.isolate", json!({"id": group.0})).unwrap();
app.session.doc_mut().unwrap().active_layer = Some(first);
crate::menus::invoke(&mut app, "edit.paste", json!({}));
app.run("object.exitIsolation", json!({})).unwrap();
app.run("layer.setProps", json!({"ids": [first.0], "locked": true})).unwrap();
placed(&mut app);
let st = app.session.doc().unwrap();
assert_eq!(st.selection.objects.first().and_then(|i| st.doc.parent_of(*i)), Some(group), "pasted into the group isolated at the paste");
assert_eq!(st.isolation, None, "the isolation ended meanwhile stays ended");
}
/// A bitmap pasted from another app whose layer is locked while it is decoded goes into the layer
/// current then, also when the objects selected at the paste, which it selects again, are in
/// another layer.
#[test]
fn a_bitmap_whose_layer_is_locked_meanwhile_is_not_pasted_next_to_the_selection() {
let (mut app, _) = pasting_app(true, Some(Flavour { mime: PNG, data: picture(Png, 60, 40) }), None, true);
let first = app.session.doc().unwrap().doc.layers[0].id;
app.run("layer.new", json!({})).unwrap();
let selected = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap()["id"].clone();
let second = app.session.doc().unwrap().current_layer().unwrap();
app.run("layer.new", json!({})).unwrap();
let third = app.session.doc().unwrap().current_layer().unwrap();
app.run("select.set", json!({"ids": [selected]})).unwrap();
app.run("layer.setCurrent", json!({"id": first.0})).unwrap();
assert_eq!(app.session.doc().unwrap().selection.objects.len(), 1);
crate::menus::invoke(&mut app, "edit.paste", json!({}));
app.run("layer.setProps", json!({"ids": [first.0], "locked": true})).unwrap();
app.run("layer.setCurrent", json!({"id": third.0})).unwrap();
app.run("select.none", json!({})).unwrap();
placed(&mut app);
let st = app.session.doc().unwrap();
let pasted = st.selection.objects.first().and_then(|i| st.doc.layer_containing(*i));
assert_eq!(pasted, Some(third), "pasted into the current layer, not {second:?}");
}
/// In Draw Inside, a bitmap decoded off the UI thread is pasted inside the object Draw Inside draws
/// into, in another layer, when the layer current at the paste is locked meanwhile.
#[test]
fn a_bitmap_pasted_in_draw_inside_stays_inside_when_its_layer_is_locked() {
let (mut app, _) = pasting_app(true, Some(Flavour { mime: PNG, data: picture(Png, 60, 40) }), None, true);
let first = app.session.doc().unwrap().doc.layers[0].id;
app.run("layer.new", json!({})).unwrap();
let path = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 200, "height": 200})).unwrap()["id"].clone();
app.run("layer.new", json!({})).unwrap();
let third = app.session.doc().unwrap().current_layer().unwrap();
app.run("select.set", json!({"ids": [path]})).unwrap();
app.run("view.drawMode", json!({"mode": "inside"})).unwrap();
app.run("select.none", json!({})).unwrap();
app.run("layer.setCurrent", json!({"id": first.0})).unwrap();
crate::menus::invoke(&mut app, "edit.paste", json!({}));
app.run("view.drawMode", json!({"mode": "normal"})).unwrap();
app.run("layer.setProps", json!({"ids": [first.0], "locked": true})).unwrap();
app.run("layer.setCurrent", json!({"id": third.0})).unwrap();
placed(&mut app);
let st = app.session.doc().unwrap();
let group = st.selection.objects.first().and_then(|i| st.doc.parent_of(*i));
assert!(
group.is_some_and(|g| st.doc.node(g).is_some_and(|n| n.children().is_some_and(|c| c.iter().any(|n| n.id.0 == path.as_u64().unwrap())))),
"pasted inside the path"
);
}
/// Paste in Front does not paste inside the object Draw Inside draws into: a bitmap decoded off the
/// UI thread goes into the layer current at the paste when that object is locked meanwhile.
#[test]
fn a_bitmap_pasted_in_front_in_draw_inside_keeps_its_layer() {
let (mut app, _) = pasting_app(true, Some(Flavour { mime: PNG, data: picture(Png, 60, 40) }), None, true);
let first = app.session.doc().unwrap().doc.layers[0].id;
app.run("layer.new", json!({})).unwrap();
let second = app.session.doc().unwrap().current_layer().unwrap();
let path = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 200, "height": 200})).unwrap()["id"].clone();
app.run("layer.new", json!({})).unwrap();
let third = app.session.doc().unwrap().current_layer().unwrap();
app.run("select.set", json!({"ids": [path]})).unwrap();
app.run("view.drawMode", json!({"mode": "inside"})).unwrap();
app.run("select.none", json!({})).unwrap();
app.run("layer.setCurrent", json!({"id": first.0})).unwrap();
crate::menus::invoke(&mut app, "edit.pasteInFront", json!({}));
app.run("layer.setProps", json!({"ids": [second.0], "locked": true})).unwrap();
app.run("layer.setCurrent", json!({"id": third.0})).unwrap();
placed(&mut app);
let st = app.session.doc().unwrap();
assert_eq!(st.selection.objects.first().and_then(|i| st.doc.layer_containing(*i)), Some(first), "pasted into the layer current at the paste");
}
/// A paste waiting for its Swatch Conflict dialog whose layer is locked before the dialog's OK
/// goes into the layer current at the OK, not into the topmost layer.
#[test]
fn a_deferred_swatch_paste_whose_layer_is_locked_meanwhile_uses_the_current_layer() {
let (mut app, _) = pasting_app(true, None, None, true);
app.run("swatch.new", json!({"name": "Brand", "color": "#ff0000", "global": true})).unwrap();
let source = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap()["id"].clone();
app.run("paint.setFill", json!({"ids": [source], "swatch": "Brand"})).unwrap();
app.run("edit.copy", json!({})).unwrap();
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
app.run("swatch.new", json!({"name": "Brand", "color": "#0000ff", "global": true})).unwrap();
let first = app.session.doc().unwrap().doc.layers[0].id;
app.run("layer.new", json!({})).unwrap();
let second = app.session.doc().unwrap().current_layer().unwrap();
app.run("layer.new", json!({})).unwrap();
app.run("layer.setCurrent", json!({"id": first.0})).unwrap();
app.run("select.none", json!({})).unwrap();
crate::menus::invoke(&mut app, "edit.paste", json!({}));
placed(&mut app);
assert_eq!(app.ui.dialog.as_ref().unwrap().kind, crate::dialogs::swatch_conflict::KIND);
app.run("layer.setProps", json!({"ids": [first.0], "locked": true})).unwrap();
app.run("layer.setCurrent", json!({"id": second.0})).unwrap();
app.ui.dialog.as_mut().unwrap().fields.insert("choice".into(), json!("add"));
crate::dialogs::confirm(&mut app).unwrap();
let st = app.session.doc().unwrap();
assert_eq!(st.selection.objects.first().and_then(|i| st.doc.layer_containing(*i)), Some(second));
}
#[test]
fn a_queued_paste_stacks_after_a_deferred_swatch_confirmation() {
for id in ["edit.pasteInFront", "edit.pasteInBack"] {
@@ -970,6 +1098,166 @@ fn a_bitmap_read_off_the_ui_thread_is_pasted_into_its_layer() {
assert_eq!(st.current_layer(), Some(second), "the layer of the object selected meanwhile stays current");
}
/// An app placing off the UI thread with three layers, the bottom one current → the app, a TIFF
/// file to place and the layers from the bottom up.
fn three_layers(test: &str) -> (VectorcraftApp, String, [NodeId; 3]) {
let mut app = app(true);
let path = saved(test, "a.tif", &picture(Tiff, 60, 40));
let first = app.session.doc().unwrap().doc.layers[0].id;
app.run("layer.new", json!({})).unwrap();
let second = app.session.doc().unwrap().current_layer().unwrap();
app.run("layer.new", json!({})).unwrap();
let third = app.session.doc().unwrap().current_layer().unwrap();
app.run("layer.setCurrent", json!({"id": first.0})).unwrap();
(app, path, [first, second, third])
}
/// A file read off the UI thread after the Place dialog's OK is placed into the layer that was
/// current at the OK, and a layer made current while it is read stays current.
#[test]
fn a_file_read_off_the_ui_thread_is_placed_into_its_layer() {
let (mut app, a, [first, second, _]) = three_layers("into-its-layer");
app.run("file.place", json!({"paths": [a]})).unwrap();
assert_eq!(crate::dialogs::confirm(&mut app).unwrap()["background"], true);
app.run("layer.setCurrent", json!({"id": second.0})).unwrap();
placed(&mut app);
let st = app.session.doc().unwrap();
assert_eq!(st.doc.layer_containing(st.selection.objects[0]), Some(first), "placed into the layer current at the OK");
assert_eq!(st.current_layer(), Some(second), "the layer made current meanwhile stays current");
}
/// A file dropped on the canvas goes into the layer current at the drop, not into a group in
/// another layer isolated while the file is read, and the group stays isolated.
#[test]
fn a_dropped_file_is_placed_into_the_layer_current_at_the_drop() {
let (mut app, a, [first, second, _]) = three_layers("drop-into-its-layer");
app.run("layer.setCurrent", json!({"id": second.0})).unwrap();
let squares: Vec<Value> =
(0..2).map(|i| app.run("shape.rectangle", json!({"x": 10 + 30 * i, "y": 10, "width": 20, "height": 20})).unwrap()["id"].clone()).collect();
app.run("select.set", json!({"ids": squares})).unwrap();
let group = NodeId(app.run("object.group", json!({})).unwrap()["id"].as_u64().unwrap());
app.run("select.none", json!({})).unwrap();
app.run("layer.setCurrent", json!({"id": first.0})).unwrap();
let doc = app.session.doc().unwrap().uid;
let drop = DropTarget::Place(DropAt { doc, reverts: 0, at: vectorcraft_geom::Point::new(200.0, 150.0), embed: false });
crate::place::drop_files(&mut app, vec![(drop, ("a.tif".into(), Some(a), vec![]))]);
app.run("object.isolate", json!({"id": group.0})).unwrap();
placed(&mut app);
let st = app.session.doc().unwrap();
assert_eq!(st.doc.parent_of(st.selection.objects[0]), Some(first), "placed into the layer current at the drop");
assert_eq!(st.isolation, Some(group), "the group stays isolated");
}
/// An object selected in another layer while a placed file is read makes that layer current, and
/// it stays current after the file is placed into the layer current at the OK.
#[test]
fn a_file_placed_while_an_object_in_another_layer_is_selected_keeps_its_layer() {
let (mut app, a, [first, second, _]) = three_layers("select-meanwhile");
app.run("layer.setCurrent", json!({"id": second.0})).unwrap();
let square = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap()["id"].clone();
app.run("layer.setCurrent", json!({"id": first.0})).unwrap();
app.run("select.none", json!({})).unwrap();
app.run("file.place", json!({"paths": [a]})).unwrap();
crate::dialogs::confirm(&mut app).unwrap();
app.run("select.set", json!({"ids": [square]})).unwrap();
assert_eq!(app.session.doc().unwrap().current_layer(), Some(second));
placed(&mut app);
let st = app.session.doc().unwrap();
assert_eq!(st.doc.layer_containing(st.selection.objects[0]), Some(first), "placed into the layer current at the OK");
assert_eq!(st.current_layer(), Some(second), "the layer of the object selected meanwhile stays current");
}
/// Replace swaps the object selected at the OK in its own layer, and a layer made current while the
/// file is read stays current after Replace selects that object again.
#[test]
fn a_replace_read_off_the_ui_thread_keeps_the_layer_made_current_meanwhile() {
let (mut app, a, [first, second, _]) = three_layers("replace-meanwhile");
app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap();
crate::place::run_for_user(&mut app, &json!({"path": a, "replace": true})).unwrap();
app.run("select.none", json!({})).unwrap();
app.run("layer.setCurrent", json!({"id": second.0})).unwrap();
placed(&mut app);
let st = app.session.doc().unwrap();
let image = st.selection.objects[0];
assert!(matches!(st.doc.node(image).map(|n| &n.kind), Some(vectorcraft_doc::NodeKind::Image(_))), "{}", app.ui.status);
assert_eq!(st.doc.layer_containing(image), Some(first), "the image takes the replaced object's place");
assert_eq!(st.current_layer(), Some(second), "the layer made current meanwhile stays current");
}
/// A file whose layer is deleted or locked while it is read goes where new art goes now: into the
/// layer current then, not into the topmost layer.
#[test]
fn a_file_whose_layer_is_deleted_or_locked_meanwhile_goes_into_the_current_layer() {
let mut found = vec![];
let mut wanted = vec![];
for change in ["delete", "lock", "hide"] {
let (mut app, a, [first, second, _]) = three_layers(&format!("layer-{change}"));
app.run("file.place", json!({"paths": [a]})).unwrap();
crate::dialogs::confirm(&mut app).unwrap();
match change {
"delete" => app.run("layer.delete", json!({"ids": [first.0]})).unwrap(),
"lock" => app.run("layer.setProps", json!({"ids": [first.0], "locked": true})).unwrap(),
_ => app.run("layer.setProps", json!({"ids": [first.0], "visible": false})).unwrap(),
};
app.run("layer.setCurrent", json!({"id": second.0})).unwrap();
placed(&mut app);
let st = app.session.doc().unwrap();
let image = st.selection.objects.first().copied();
found.push((change, image.and_then(|i| st.doc.layer_containing(i)), st.current_layer()));
wanted.push((change, Some(second), Some(second)));
}
assert_eq!(found, wanted, "placed into the current layer, which stays current");
}
/// Place does not draw inside an object: with Draw Inside on for an object in another layer, a file
/// whose layer is locked while it is read goes into the layer current then.
#[test]
fn a_file_placed_with_draw_inside_on_follows_its_layer() {
let (mut app, a, [first, second, _]) = three_layers("draw-inside");
app.run("layer.setCurrent", json!({"id": second.0})).unwrap();
let inside = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 200, "height": 200})).unwrap()["id"].clone();
app.run("select.set", json!({"ids": [inside]})).unwrap();
app.run("view.drawMode", json!({"mode": "inside"})).unwrap();
app.run("layer.setCurrent", json!({"id": first.0})).unwrap();
app.run("select.none", json!({})).unwrap();
assert_eq!(app.session.draw_inside.map(|t| t.0), inside.as_u64());
app.run("file.place", json!({"paths": [a]})).unwrap();
crate::dialogs::confirm(&mut app).unwrap();
app.run("layer.setProps", json!({"ids": [first.0], "locked": true})).unwrap();
app.run("layer.setCurrent", json!({"id": second.0})).unwrap();
placed(&mut app);
let st = app.session.doc().unwrap();
assert_eq!(st.selection.objects.first().and_then(|i| st.doc.layer_containing(*i)), Some(second), "placed into the current layer");
}
/// A bitmap pasted from another app whose layer is deleted, locked or hidden while it is decoded
/// goes into the layer current then, not into the topmost layer.
#[test]
fn a_bitmap_whose_layer_is_deleted_or_locked_meanwhile_is_pasted_into_the_current_layer() {
let mut found = vec![];
let mut wanted = vec![];
for change in ["delete", "lock", "hide"] {
let (mut app, _) = pasting_app(true, Some(Flavour { mime: PNG, data: picture(Png, 60, 40) }), None, true);
let first = app.session.doc().unwrap().doc.layers[0].id;
app.run("layer.new", json!({})).unwrap();
let second = app.session.doc().unwrap().current_layer().unwrap();
app.run("layer.new", json!({})).unwrap();
app.run("layer.setCurrent", json!({"id": first.0})).unwrap();
crate::menus::invoke(&mut app, "edit.paste", json!({}));
match change {
"delete" => app.run("layer.delete", json!({"ids": [first.0]})).unwrap(),
"lock" => app.run("layer.setProps", json!({"ids": [first.0], "locked": true})).unwrap(),
_ => app.run("layer.setProps", json!({"ids": [first.0], "visible": false})).unwrap(),
};
app.run("layer.setCurrent", json!({"id": second.0})).unwrap();
placed(&mut app);
let st = app.session.doc().unwrap();
found.push((change, st.selection.objects.first().and_then(|i| st.doc.layer_containing(*i))));
wanted.push((change, Some(second)));
}
assert_eq!(found, wanted, "pasted into the current layer");
}
/// The Place dialog's OK with one file, with several (the place cursor and its thumbnails), a
/// drop on the canvas and [`crate::io::place_bytes`] read their files off the UI thread;
/// `file.place` and `file.place.queue` from MCP and scripts read them at once, with the replies