diff --git a/common/src/app/common/logic/duplicate.cljc b/common/src/app/common/logic/duplicate.cljc index 72f620befe..ac69cddd1f 100644 --- a/common/src/app/common/logic/duplicate.cljc +++ b/common/src/app/common/logic/duplicate.cljc @@ -552,11 +552,14 @@ objects (pcb/get-objects changes) - ;; the new copies that no other copy holds + ;; the new copies that no other copy holds, under a parent other than + ;; the one their source has on the page heads (filterv (fn [id] - (let [shape (get objects id)] + (let [shape (get objects id) + source (some (fn [[old new]] (when (= new id) old)) ids-map)] (and (ctk/instance-head? shape) - (= 1 (count (ctn/get-parent-copy-heads objects shape)))))) + (= 1 (count (ctn/get-parent-copy-heads objects shape))) + (not= (:parent-id shape) (get-in page [:objects source :parent-id]))))) (keep ids-map ids))] (-> changes diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 0c461fc29a..55c97d8240 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -4294,3 +4294,16 @@ :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]]})))) + +(t/deftest generated-a-duplicate-in-place-or-a-paste-marks-only-the-geometry-it-moves + ;; a stale copy duplicated in place marks nothing; a pasted copy keeps what + ;; it authored where it lands + (t/is (map? (cg/run {:world [2 0 {:variants true :text-styles false :library-variants false :stale-libraries true + :layout nil :layout-item-margins false :grid-square false :library-depth 2 + :library true :rich-variants false :layout-children false :library-text false + :grid-empty false :layout-copies false :text false}] + :ops [[:library-delete 1] [:library-restore] [:library-transform 11 5] [:duplicate 11]]}))) + (t/is (map? (cg/run {:world [2 0 {:variants true :text-styles false :layout :grid :layout-item-margins false + :grid-square false :library true :rich-variants true :layout-children false + :grid-empty false :layout-copies false :text true}] + :ops [[:switch 11] [:switch 5] [:nest 17] [:add-child 15] [:rotate 15] [:style 12 9 1] [:paste 12]]}))))