From 58ee5519d38ed89fc554a7a55a8dfca206bc613a Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 10 Nov 2026 13:19:11 +0100 Subject: [PATCH] :bug: Carry no switched text content that shows what the new copy shows A copy text can hold a typography file without a typography id, which the reference rule counts as a typography override. A switch carried it, and merging the overrides then dropped the reference, since no unit the typography sets was carried. The merged content showed the letters and styles of the new copy and differed from it only by nil typography keys, yet the switch wrote it and marked the content group touched with no text group behind it. A text content the switch would carry is now compared with the new copy's by its letters and styles, and one that differs in none is not carried. Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | :world | :baseline | :now | :mean | :ratio | |------------------------------------+-----------+--------+--------+--------| | deepest-edit-through-three-levels | 35.215 | 19.246 | 20.089 | 0.55 | | edit-through-a-chain-of-dependents | 68.931 | 38.107 | 39.639 | 0.55 | | library-update-into-copies | 83.083 | 46.922 | 48.603 | 0.56 | | main-edit-among-many-shapes | 4.837 | 1.958 | 2.141 | 0.4 | | main-edit-into-10-copies | 1.79 | 0.99 | 1.079 | 0.55 | | main-edit-into-100-copies | 15.415 | 9.335 | 9.733 | 0.61 | | main-edit-into-1000-copies | 153.086 | 92.647 | 96.02 | 0.61 | | variant-switch-into-copies | 32.052 | 20.358 | 20.802 | 0.64 | AI-assisted-by: claude-opus-5-5 --- common/src/app/common/logic/swap.cljc | 9 ++++++++- common/test/common_tests/logic/composable_gen_test.cljc | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/logic/swap.cljc b/common/src/app/common/logic/swap.cljc index 1b6ded2c51..005a5121ce 100644 --- a/common/src/app/common/logic/swap.cljc +++ b/common/src/app/common/logic/swap.cljc @@ -289,8 +289,15 @@ ;; 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) + (cond + (contains? #{:points :selrect :width :height :rotation} attr) (gsh/close-attrs? attr attr-val (get current-shape attr)) + + ;; a text showing the letters and styles of the new copy is no override + text-change? + (empty? (txt/override-groups (get current-shape attr) attr-val)) + + :else (= attr-val (get current-shape attr)))) [] (cond-> [] diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 807930f7e5..ef21719acb 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2072,6 +2072,13 @@ :ops [[:combine 8] [:transform 13 4 0 6] [:nest 8] [:make-variant] [:make-variant 7] [:make-variant] [:transform 0 9 0 2] [:combine 9] [:switch 6]]})))) +(t/deftest switching-a-text-with-a-typography-file-but-no-typography-carries-no-override + (t/is (map? (cg/run {:world [1 0 {:variants true :text-styles false :layout :grid :variant-diff false + :layout-item-margins false :grid-square false :rich-variants true + :layout-children false :grid-empty false :layout-copies false :text false}] + :ops [[:text-style 3 8 1] [:text-style 3 1] [:nest] [:switch] [:text-style 0 8 1] + [:switch 1]]})))) + (t/deftest turning-a-flipped-copy-turns-a-child-stored-as-the-other-mirror-turn (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