🐛 Make a kept swapped child follow its parent's change on switch

A variant switch moves a swapped child of the old copy into the new one
and gives it the place of the new variant's occupant. The new copy is
created at its main's size, so in a copy that a layout had made wider the
child kept the size and place the wider parent gave it: a child the user
moved, with a right constraint, stayed by the old right edge, and one with
a scale constraint kept its grown size, which the layout then scaled again.

The child and its subtree now follow the change from the old parent to the
new one through their own constraints before taking that place.

The switch tests of develop's swapped and moved children placement cover
it.

Benchmark (scripts/bench-components, ms, lower 2.5% quantile):

| world                              | baseline |     now | ratio |
|------------------------------------+----------+---------+-------|
| deepest-edit-through-three-levels  |   35.215 |  21.321 |  0.61 |
| edit-through-a-chain-of-dependents |   68.931 |  42.794 |  0.62 |
| library-update-into-copies         |   83.083 |  50.007 |  0.60 |
| main-edit-among-many-shapes        |    4.837 |   2.297 |  0.47 |
| main-edit-into-10-copies           |     1.79 |   1.003 |  0.56 |
| main-edit-into-100-copies          |   15.415 |   9.732 |  0.63 |
| main-edit-into-1000-copies         |  153.086 |   98.04 |  0.64 |
| variant-switch-into-copies         |   32.052 |   20.73 |  0.65 |

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-04 23:16:32 +01:00
parent b64de794a2
commit 288e43dd7a

View File

@ -296,6 +296,16 @@
(pcb/change-parent (:parent-id related-shape-in-new) [child-at-root] pos
{:allow-altering-copies true}))
;; the child and its subtree follow the change from the old parent to
;; the new one, each through its own constraints
changes (-> (cll/generate-follow-parent changes
(ctn/make-container (assoc page :objects (pcb/get-objects changes)) :page)
(get (pcb/get-objects changes) (:id orig-swapped-child))
(get (:objects page) (:parent-id orig-swapped-child))
current-parent
nil)
(pcb/apply-changes-local))
objects (pcb/get-objects changes)
child-id (:id orig-swapped-child)
file {:id (:id ldata) :data ldata}