mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Find the main of a copy's child through every parent head
The remote shape of a copy's child was looked up in the component of its outermost copy, then in the component of its nearest head. A copy nested in a swapped copy refers to the main of the swapped copy's component, which is neither: a switch of that nested copy found no remote shape for it, paired a touched child with the new root and crashed comparing their geometry. The fallback tries the component of each parent head, from the nearest one up. Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | world | baseline | now | ratio | |------------------------------------+----------+---------+-------| | deepest-edit-through-three-levels | 35.215 | 21.863 | 0.62 | | edit-through-a-chain-of-dependents | 68.931 | 39.725 | 0.58 | | library-update-into-copies | 83.083 | 48.505 | 0.58 | | main-edit-among-many-shapes | 4.837 | 2.747 | 0.57 | | main-edit-into-10-copies | 1.79 | 1.019 | 0.57 | | main-edit-into-100-copies | 15.415 | 9.565 | 0.62 | | main-edit-into-1000-copies | 153.086 | 100.188 | 0.65 | | variant-switch-into-copies | 32.052 | 21.229 | 0.66 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
4266de0f7c
commit
a7e39ae8cb
@ -550,13 +550,15 @@
|
||||
[remote-shape component-container component-file]
|
||||
(if (some? remote-shape)
|
||||
[remote-shape component-container component-file]
|
||||
;; If not found, try the case of this being a fostered or swapped children
|
||||
(let [head-instance (ctn/get-head-shape (:objects container) shape)
|
||||
component-file (get-in libraries [(:component-file head-instance) :data])
|
||||
head-component (ctkl/get-component component-file (:component-id head-instance) true)
|
||||
remote-shape' (get-ref-shape component-file head-component shape)
|
||||
component-container' (get-component-container component-file head-component)]
|
||||
[remote-shape' component-container' component-file]))]
|
||||
;; A fostered or swapped child refers to the main of a nested
|
||||
;; head, tried from the nearest one up
|
||||
(some (fn [head]
|
||||
(let [component-file (get-in libraries [(:component-file head) :data])
|
||||
head-component (ctkl/get-component component-file (:component-id head) true)
|
||||
remote-shape' (get-ref-shape component-file head-component shape)]
|
||||
(when (some? remote-shape')
|
||||
[remote-shape' (get-component-container component-file head-component) component-file])))
|
||||
(reverse (ctn/get-parent-heads (:objects container) shape))))]
|
||||
|
||||
(if (nil? remote-shape)
|
||||
nil
|
||||
|
||||
@ -1178,3 +1178,12 @@
|
||||
:library true :rich-variants true :layout-children true :library-text true
|
||||
:grid-empty true :layout-copies true :text true}]
|
||||
:ops [[:style 13 29 1] [:rotate 6 0 0 0]]}))))
|
||||
|
||||
(t/deftest generated-switch-finds-the-main-of-a-copy-in-a-swapped-copy
|
||||
;; a switch of a nested copy inside a swapped copy, itself inside a copy of
|
||||
;; a deleted component, carries its child's text override from the main
|
||||
;; the swapped copy holds
|
||||
(t/is (map? (cg/run {:world [2 1 {:variants true :text-styles true :layout nil :layout-item-margins false
|
||||
:grid-square false :library true :rich-variants true :layout-children false
|
||||
:grid-empty false :layout-copies true :text true}]
|
||||
:ops [[:nest 6 0 0 0] [:text 6 0 0 0] [:delete 6 0 0 0] [:swap 6 0 0 0] [:switch 0 0 0 0]]}))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user