mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 09:42:01 +00:00
🐛 Preserve unflipped group flags during regrouping
Regrouping rewrote nil or absent flip flags as false. Component sync then failed exact whole-file undo even when group geometry returned correctly. Keep the original value and key presence when both the old and recalculated axis are unflipped. Continue recalculating real flips. The independent geometry regression fails eight of 30 assertions before the fix. It and the retained-group-frame sync control now pass unchanged, including exact whole-file undo and redo. Browser data checks pass 90 assertions across maps, records and ShapeProxy objects; the browser uses SVG, so this does not claim an initialized WASM render check. Refresh only case AM's three common and three frontend golden digests. Reviewed state changes contain only false-to-nil group flip values; geometry and touched values are unchanged. No comparison tolerance changes. Validate the combined tree with the F256/F257 fixture corrections, committed separately next. Full frontend passes 1793 tests / 15589 assertions; backend passes 1838 / 9293 and exporter 16 / 40. Consumer lint/format and frontend lint pass. Full frontend format still reports two existing alignment errors in the unchanged plugin library test. Full common JVM passes 2043 tests / 33558 assertions and JavaScript passes 1979 / 32265. Common lint and format pass. All six generated component properties pass 40 programs each at seed 712 in both runtimes. No fresh 5000-program gate ran. The isolated component benchmark passes without regression flags. Compare lower-quantile milliseconds with the existing baseline; do not replace it. The benchmark warns that the machine/JVM differs, so ratios are rough. World Baseline Now Ratio Main into 10 copies 1.790 0.996 0.56 Main into 100 copies 15.415 10.043 0.65 Main into 1000 copies 153.086 99.513 0.65 Three nesting levels 35.215 21.189 0.60 Dependency chain 68.931 36.537 0.53 Library update 83.083 46.847 0.56 Many plain shapes 4.837 2.479 0.51 Variant switch 32.052 19.992 0.62 AI-assisted-by: gpt-6
This commit is contained in:
parent
31f9350d08
commit
2638dd3d63
@ -436,7 +436,15 @@
|
||||
new-selrect
|
||||
(-> new-points
|
||||
(gco/transform-points sr-transform)
|
||||
(grc/points->rect))]
|
||||
(grc/points->rect))
|
||||
|
||||
preserve-unflipped
|
||||
(fn [after attr]
|
||||
(if (or (get group attr) (get after attr))
|
||||
after
|
||||
(if (contains? group attr)
|
||||
(assoc after attr (get group attr))
|
||||
(dissoc after attr))))]
|
||||
|
||||
;; Updates the shape and the applytransform-rect will update the other properties
|
||||
(-> group
|
||||
@ -448,7 +456,11 @@
|
||||
;; need to remove the flip flags
|
||||
(assoc :flip-x false)
|
||||
(assoc :flip-y false)
|
||||
(apply-transform (gmt/matrix)))))
|
||||
(apply-transform (gmt/matrix))
|
||||
;; Regrouping still recalculates real flips. An unchanged unflipped
|
||||
;; axis keeps its nil/false/absent value for exact undo and redo.
|
||||
(preserve-unflipped :flip-x)
|
||||
(preserve-unflipped :flip-y))))
|
||||
|
||||
(defn update-mask-selrect
|
||||
[masked-group children]
|
||||
|
||||
@ -39,6 +39,25 @@
|
||||
:height 20}
|
||||
params)))))
|
||||
|
||||
(t/deftest regrouping-preserves-the-representation-of-unflipped-axes
|
||||
(doseq [horizontal [{} {:flip-x nil} {:flip-x false}]
|
||||
vertical [{} {:flip-y nil} {:flip-y false}]]
|
||||
(let [group (merge (dissoc (create-test-shape :group) :flip-x :flip-y) horizontal vertical)
|
||||
child (create-test-shape :rect)
|
||||
after (gsh/update-group-selrect group [child])]
|
||||
(t/is (= (select-keys group [:flip-x :flip-y]) (select-keys after [:flip-x :flip-y])))
|
||||
(t/is (gsh/close-attrs? :points (:points child) (:points after) 1e-10))
|
||||
(t/is (= (select-keys after [:flip-x :flip-y])
|
||||
(select-keys (gsh/update-group-selrect after [child]) [:flip-x :flip-y]))))))
|
||||
|
||||
(t/deftest regrouping-still-recalculates-stale-flip-flags
|
||||
(let [group (create-test-shape :group {:flip-x true :flip-y true})
|
||||
child (create-test-shape :rect)
|
||||
after (gsh/update-group-selrect group [child])]
|
||||
(t/is (false? (:flip-x after)))
|
||||
(t/is (false? (:flip-y after)))
|
||||
(t/is (gsh/close-attrs? :points (:points child) (:points after) 1e-10))))
|
||||
|
||||
(t/deftest transform-shapes
|
||||
(t/testing "Shape without modifiers should stay the same"
|
||||
(t/are [type]
|
||||
|
||||
@ -891,6 +891,40 @@
|
||||
(t/is (= (:shapes copy-group) (:shapes copy-group'')))
|
||||
(t/is (= (geometry copy-group) (geometry copy-group'')))))
|
||||
|
||||
(t/deftest test-sync-new-child-follows-an-overridden-group-frame
|
||||
(let [file (-> (thf/sample-file :file1)
|
||||
(add-group-component-with-copy)
|
||||
(touch-copy-group-geometry)
|
||||
(ths/add-sample-shape :free-shape :x 60 :y 60 :width 10 :height 10))
|
||||
page (thf/current-page file)
|
||||
changes1 (cls/generate-relocate (-> (pcb/empty-changes nil (:id page))
|
||||
(pcb/with-objects (:objects page)))
|
||||
(thi/id :main-group) 0 #{(thi/id :free-shape)})
|
||||
updated-file (-> (thf/apply-changes file changes1)
|
||||
(update-fill :main-child1 "#fabada"))
|
||||
changes2 (sync-file-changes updated-file)
|
||||
file' (thf/apply-changes updated-file changes2)
|
||||
file'' (thf/apply-undo-changes file' changes2)
|
||||
redone (thf/apply-changes file'' changes2)
|
||||
copy-group (ths/get-shape file :copy-group)
|
||||
copy-group' (ths/get-shape file' :copy-group)
|
||||
added (ths/get-shape-by-id file' (first (:shapes copy-group')))]
|
||||
;; The main grew from 30x10 to 60x60. The copy keeps its authored frame;
|
||||
;; its new child follows the resulting 1/2 and 1/6 size ratios.
|
||||
(t/is (= (geometry copy-group) (geometry copy-group')))
|
||||
(t/is (= #{:geometry-group} (:touched copy-group')))
|
||||
(t/is (= (thi/id :free-shape) (:shape-ref added)))
|
||||
(t/is (gsh/close-attrs? :points
|
||||
[(gpt/point 135 (/ 355.0 3)) (gpt/point 140 (/ 355.0 3))
|
||||
(gpt/point 140 120) (gpt/point 135 120)]
|
||||
(:points added) 1e-10))
|
||||
(t/is (nil? (:touched added)))
|
||||
(doseq [label [:copy-child1 :copy-child2]]
|
||||
(t/is (= (geometry (ths/get-shape file label)) (geometry (ths/get-shape file' label))))
|
||||
(t/is (= #{:geometry-group} (:touched (ths/get-shape file' label)))))
|
||||
(t/is (uc/same-state? (uc/snapshot updated-file) (uc/snapshot file'')))
|
||||
(t/is (uc/same-state? (uc/snapshot file') (uc/snapshot redone)))))
|
||||
|
||||
(t/deftest test-sync-undo-group-after-remove-and-update
|
||||
(let [;; ==== Setup
|
||||
file (-> (thf/sample-file :file1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user