📎 Hold a laid-out copy shape to no authored place in the harness

A copy shape that authored its place in a plain board, then taken into a
grid board by an ungroup of its main, is placed by that grid. The model
still compared the place it had authored. A shape a layout places is no
longer held to an authored place.

Harness only; the benchmark is not run.

Also in this commit:

- The harness changes that check the next commit, "Mark a pasted copy's geometry
  only when it changes parent".

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-13 23:29:13 +01:00
parent 92ab1a2486
commit f8f378ac74
3 changed files with 20 additions and 7 deletions

View File

@ -1146,14 +1146,16 @@
head (get after-objects new-head)
main (get after-objects (:shape-ref head))
model (shadow/duplicate model objects id (:objects (thf/current-page (tm/file after))) new-head)]
;; a copy pasted on the page keeps the orientation and size it showed,
;; which its main's need not be
;; a copy pasted on the page keeps the geometry it showed: what it
;; authored, now where it lands, and the orientation and size another
;; parent gave it, which its main's need not be
(cond-> model
(and (= kind :paste) head main (:shape-ref head)
(not (get-in model [new-head :geometry-group]))
(or (not (gmt/close? (or (:transform head) (gmt/matrix)) (or (:transform main) (gmt/matrix))))
(not (mth/close? (:width (:selrect head)) (:width (:selrect main)) 0.01))
(not (mth/close? (:height (:selrect head)) (:height (:selrect main)) 0.01))))
(or (get-in model [new-head :geometry-group])
(and (not (cfh/root? (get objects (:parent-id shape))))
(or (not (gmt/close? (or (:transform head) (gmt/matrix)) (or (:transform main) (gmt/matrix))))
(not (mth/close? (:width (:selrect head)) (:width (:selrect main)) 0.01))
(not (mth/close? (:height (:selrect head)) (:height (:selrect main)) 0.01))))))
(assoc-in [new-head :geometry-group] (shadow/author-geometry head nil))))
(:swap :switch)
(let [after-objects (all-objects after)

View File

@ -188,7 +188,10 @@
(let [frame (get objects (:frame-id shape))]
(when-not (ctl/any-layout? frame) frame))
parent)
placed (when (and objects (not (:sized? (::position (meta expected)))))
;; a layout places the shape, whatever place it authored before
laid-out (and objects (ctl/any-layout-immediate-child? objects shape)
(not (ctl/position-absolute? shape)))
placed (when (and objects (not laid-out) (not (:sized? (::position (meta expected)))))
(authored-placement expected parent shape))
;; an authored size follows its parent's later resizes through its
;; constraints too, though its place is not authored

View File

@ -4286,3 +4286,11 @@
:rich-variants true :layout-children false :grid-empty false
:layout-copies true :text true}]
:ops [[:style 14 11 1] [:text-style 14 0 1] [:nest 7] [:switch 9] [:switch 9]]}))))
(t/deftest generated-a-copy-shape-ungrouped-into-a-grid-is-placed-by-it
;; a copy shape that authored its place, then taken into a grid board by
;; an ungroup of its main, is placed by that grid
(t/is (map? (cg/run {:world [2 2 {:variants true :rich-variants true :text true :layout :grid
:layout-copies true :layout-children false}]
:ops [[:transform 7 0 0 8] [:detach 6 0 0 0] [:add-child 0] [:structure 0 2 0]
[:sync 0 0 0 0]]}))))