mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Keep the moved place of a copy child a swap replaces as its own
A copy child of a copy can be moved, which marks its geometry as its own. Swapping it for another component keeps the place it was moved to, but the new head only has the swap override, so the next sync brought it back to the place its position in the main gives it. A variant switch already marked that place as the new head's own geometry. A swap marks it too, and the model expects that place as authored. Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | world | baseline | now | ratio | |------------------------------------+----------+---------+-------| | deepest-edit-through-three-levels | 35.215 | 21.099 | 0.60 | | edit-through-a-chain-of-dependents | 68.931 | 41.629 | 0.60 | | library-update-into-copies | 83.083 | 52.415 | 0.63 | | main-edit-among-many-shapes | 4.837 | 2.644 | 0.55 | | main-edit-into-10-copies | 1.79 | 1.104 | 0.62 | | main-edit-into-100-copies | 15.415 | 10.707 | 0.69 | | main-edit-into-1000-copies | 153.086 | 98.141 | 0.64 | | variant-switch-into-copies | 32.052 | 22.688 | 0.71 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
c095c6cce6
commit
a737c17788
@ -606,7 +606,7 @@
|
||||
changes)))
|
||||
|
||||
(defn- keep-moved-placement
|
||||
"A switch keeps the place of the copy shape `original-shape` it replaces.
|
||||
"A swap keeps the place of the copy shape `original-shape` it replaces.
|
||||
Inside a copy, a first corner that the position of `new-shape` would not
|
||||
give it needs a geometry override to survive later sync."
|
||||
[changes original-shape new-shape page libraries]
|
||||
@ -672,10 +672,9 @@
|
||||
|
||||
changes (sync-restored-position changes page libraries (:id new-shape))
|
||||
|
||||
changes (cond-> changes
|
||||
changes (cond-> (keep-moved-placement changes shape new-shape page libraries)
|
||||
keep-touched?
|
||||
(-> (keep-moved-placement shape new-shape page libraries)
|
||||
(keep-placement-overrides shape new-shape)))
|
||||
(keep-placement-overrides shape new-shape))
|
||||
|
||||
;; Replacement keeps the head id and its cell. Cleanup during the
|
||||
;; temporary deletion must not change the parent's placement data.
|
||||
|
||||
@ -1100,3 +1100,11 @@
|
||||
(t/is (map? (cg/run {:world [3 2 {:variants true :text-styles true :layout :flex :variant-diff false :rich-variants true
|
||||
:layout-children true :layout-copies true :text true}]
|
||||
:ops [[:delete 6 0 0 0] [:swap 20 0 0 0] [:nest 7 0 0 0] [:style 13 27 1] [:switch 0 0 0 0]]}))))
|
||||
|
||||
(t/deftest generated-swap-keeps-a-moved-copy-child-in-place-as-its-own
|
||||
;; a copy child of a copy moved and swapped for another component keeps
|
||||
;; the moved place as its own geometry
|
||||
(t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout nil :variant-diff false
|
||||
:layout-item-margins false :grid-square false :rich-variants true
|
||||
:layout-children false :grid-empty false :layout-copies true :text true}]
|
||||
:ops [[:text 14 0 0 0] [:nest 0 0 0 0] [:transform 0 0 0 18] [:swap 12 0 0 0]]}))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user