🐛 Keep a cell a resize splits in one piece

Resizing a grid cell over part of a cell that spans several tracks
moves that cell to the first area left of it and adds new cells for
the others, but it added one for the first area as well, so two cells
held the same place: the moved one with its shapes and an empty one
that a later assignment filled. The grid editor's cell handles and the
sidebar's cell position reach it. New cells now cover only the areas
the moved cell does not take.

Test: resizing-a-cell-over-part-of-a-span-leaves-the-rest-of-the-span-one-cell
(the grid gate program of seed 660536824).

Benchmark (scripts/bench-components, ms, lower 2.5% quantile), measured
with the next commit's change in the tree as well:
|                             :world | :baseline |    :now |   :mean | :ratio |
|------------------------------------+-----------+---------+---------+--------|
|  deepest-edit-through-three-levels |    35.215 |  21.827 |  22.409 |   0.62 |
| edit-through-a-chain-of-dependents |    68.931 |  45.406 |  46.777 |   0.66 |
|         library-update-into-copies |    83.083 |  56.396 |   58.29 |   0.68 |
|        main-edit-among-many-shapes |     4.837 |   2.456 |   2.809 |   0.51 |
|           main-edit-into-10-copies |      1.79 |   1.143 |   1.177 |   0.64 |
|          main-edit-into-100-copies |    15.415 |   11.12 |  11.591 |   0.72 |
|         main-edit-into-1000-copies |   153.086 | 111.472 | 118.427 |   0.73 |
|         variant-switch-into-copies |    32.052 |  22.527 |  23.487 |    0.7 |

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-12 10:13:33 +01:00
parent d5cdebc478
commit 1374a897b7
2 changed files with 14 additions and 1 deletions

View File

@ -1461,7 +1461,7 @@
(update-in $ [:layout-grid-cells (:id cell)] merge (sga/area->cell-props (first new-areas)))
(reduce (fn [parent area]
(let [cell (merge (assoc grid-cell-defaults :id (uuid/next)) (sga/area->cell-props area))]
(assoc-in parent [:layout-grid-cells (:id cell)] cell))) $ new-areas))))
(assoc-in parent [:layout-grid-cells (:id cell)] cell))) $ (rest new-areas)))))
parent))]
parent)

View File

@ -1762,3 +1762,16 @@
(t/is (= [e] (:shapes (get-in result [:layout-grid-cells (:id auto-c)]))))
(t/is (= (set before) (set after)))
(t/is (= (count after) (count (distinct after)))))))
(t/deftest resizing-a-cell-over-part-of-a-span-leaves-the-rest-of-the-span-one-cell
(let [child (uuid/next)
a (make-cell :row 1 :column 1)
b (make-cell :row 1 :column 2 :column-span 2 :position :manual :shapes [child])
shape (make-grid-frame :layout-grid-rows [layout/default-track-value]
:layout-grid-columns (vec (repeat 3 layout/default-track-value))
:layout-grid-cells {(:id a) a (:id b) b})
after (layout/resize-cell-area shape 1 1 1 1 1 2)
cells (vals (:layout-grid-cells after))]
(t/is (empty? (layout/overlapping-cells after)))
(t/is (= #{[1 1 2] [1 3 1]} (set (map (juxt :row :column :column-span) cells))))
(t/is (= (assoc b :column 3 :column-span 1) (get-in after [:layout-grid-cells (:id b)])))))