mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Keep float noise out of switch geometry overrides
A variant switch carried geometry from the old copy when it differed from the new copy, using exact equality. A copy turned like its new main, equal up to 1e-14 after placement, kept a phantom geometry override. Compare the carried points, selrect, size and rotation with float tolerance before writing them. Other attributes keep exact comparison, and the position data reset still writes its nil. A random common JavaScript library run found this; its shrunk switch program fails I2 before the fix and passes unchanged after it. Switch, sync and golden suites pass; goldens are unchanged. Full suites ran once on the tree with this fix and the related fixes that follow it. Common passes lint, JVM, JavaScript and formatting: JVM 2059 tests / 33770 assertions; JavaScript 1995 / 32377. All six component properties pass 40 programs each at seed 712 in both runtimes. Full rebuilt frontend passes 1798 / 15737. Backend passes 1838 / 9293; exporter passes 16 / 40; consumer lint and formatting pass. Compare lower-quantile milliseconds with the saved baseline; keep that baseline unchanged. The machine/JVM warning makes ratios rough. No world is flagged. World Baseline Now Ratio Main into 10 copies 1.790 0.897 0.50 Main into 100 copies 15.415 8.750 0.57 Main into 1000 copies 153.086 83.056 0.54 Three nesting levels 35.215 17.460 0.50 Dependency chain 68.931 33.955 0.49 Library update 83.083 43.915 0.53 Many plain shapes 4.837 2.075 0.43 Variant switch 32.052 19.674 0.61 AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
9eda12b819
commit
c1be7835ff
@ -261,8 +261,12 @@
|
||||
:else
|
||||
(get previous-shape attr)))]
|
||||
|
||||
;; If the final attr-value is the actual value, skip
|
||||
(if (or skip? (= attr-val (get current-shape attr)))
|
||||
;; If the final attr-value is the actual value, skip. Geometry values
|
||||
;; equal up to float noise are not an override.
|
||||
(if (or skip?
|
||||
(if (contains? #{:points :selrect :width :height :rotation} attr)
|
||||
(gsh/close-attrs? attr attr-val (get current-shape attr))
|
||||
(= attr-val (get current-shape attr))))
|
||||
[]
|
||||
(cond-> []
|
||||
;; On a text-change, we want to force a position-data reset
|
||||
|
||||
@ -662,6 +662,15 @@
|
||||
(t/is (gsh/close-attrs? :height 40 (:height expected) 0.01))
|
||||
(t/is (gsh/close-attrs? :height 40 (:height child) 0.01))))
|
||||
|
||||
(t/deftest switching-to-an-equally-rotated-variant-adds-no-geometry-override
|
||||
;; The swapped copy keeps a 45 degree turn, which the new variant main
|
||||
;; already has after update-main; the switch result differs only by noise.
|
||||
(t/is (map? (cg/run {:world [2 0 {:variants true :text-styles true :layout nil :layout-item-margins false
|
||||
:library true :rich-variants true :layout-children false
|
||||
:layout-copies true :text true}]
|
||||
:ops [[:rotate 0 0 0 0] [:edit 0 0 1 1] [:update-main 0] [:delete 0]
|
||||
[:restore 0] [:nest 0 0 0 0] [:swap 0 0 0 0] [:switch 0 0 0 0]]}))))
|
||||
|
||||
(t/deftest detached-swapped-head-follows-its-own-component-without-position-overrides
|
||||
(t/is (map? (cg/run {:world [2 1 {:library true :variants true}]
|
||||
:ops [[:edit 0 0 1 2] [:update-main 0] [:library-sync]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user