Paste onto your own paste goes beside it

A paste selects what it made, and went into what was selected, so pasting
a symbol twice nested the second copy inside the first. Figma's rule:
while the selection is still exactly what the last paste made, paste goes
where that one went. Select anything else and it follows the selection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011FLuCjp9kNH6ovwJVXSbq9
This commit is contained in:
Olive Vaughn 2026-10-10 23:18:21 -04:00
parent 831843aeb0
commit 2f6fde26fb
2 changed files with 49 additions and 6 deletions

View file

@ -1,5 +1,5 @@
(ns arthur.events.lane-test
(:require [cljs.test :refer [deftest is]]
(:require [cljs.test :refer [deftest is testing]]
[arthur.domain.clip :as clip]
[arthur.domain.creation :as creation]
[arthur.domain.history :as history]
@ -316,6 +316,34 @@
(select-keys (ui/paste-destination db doc nil) [:sid :path :frame]))
"an inactive selected symbol falls back to the open symbol")))
(deftest pasting-onto-your-own-paste-goes-beside-it
(let [doc {:fps 24 :width 20 :height 20
:symbols
{:main {:id :main :frames 40
:nodes {:drawing {:id :drawing :kind :instance :z "a"
:span [0 10] :time {:at 0 :rate 1}
:source {:symbol :inside}
:playback {:in 0 :speed 1 :end :stop}}}}
:inside {:id :inside :frames 10 :nodes {}}}}
id (store/install! {:clip doc :store {}} "paste-beside")
instances #(count (get-in (store/entry id) [:clip :symbols % :nodes]))]
(reset! rf-db/app-db {:clip/current id :paint/revision 0
:ui {:open :main :selection [:node :main :drawing [:drawing]]}
:playback {:frame 2}})
(rf/dispatch-sync [::ui/copy])
(rf/dispatch-sync [::ui/select [:node :main nil []]])
(rf/dispatch-sync [::ui/paste])
(is (= 2 (instances :main)))
(rf/dispatch-sync [::ui/paste])
(rf/dispatch-sync [::ui/paste])
(is (= 4 (instances :main))
"the selected copy is a symbol under the playhead, and the paste still goes beside it")
(is (= 0 (instances :inside)))
(testing "selecting something else makes paste follow the selection again"
(rf/dispatch-sync [::ui/select [:node :main :drawing [:drawing]]])
(is (= :inside (:sid (ui/paste-destination @rf-db/app-db
(:clip (store/entry id)) {})))))))
(deftest multi-paste-uses-one-current-primary-target-and-selects-the-batch
(let [doc (fixture/document)
id (store/install! {:clip doc :store {}} "multi-paste-target")