Paste with what you copied selected goes beside it

Copying a symbol and pasting straight away tried to put the copy inside
the symbol itself, and was refused as a cycle. Figma's other case: with
the copied thing still selected, paste goes into what holds it.

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-11 00:10:25 -04:00
parent c4040c789c
commit 2b9f8638d5
2 changed files with 42 additions and 14 deletions

View file

@ -323,7 +323,11 @@
: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}}}}
:playback {:in 0 :speed 1 :end :stop}}
:other {:id :other :kind :instance :z "b"
: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]))]
@ -333,17 +337,35 @@
(rf/dispatch-sync [::ui/copy])
(rf/dispatch-sync [::ui/select [:node :main nil []]])
(rf/dispatch-sync [::ui/paste])
(is (= 2 (instances :main)))
(is (= 3 (instances :main)))
(rf/dispatch-sync [::ui/paste])
(rf/dispatch-sync [::ui/paste])
(is (= 4 (instances :main))
(is (= 5 (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]]])
(rf/dispatch-sync [::ui/select [:node :main :other [:other]]])
(is (= :inside (:sid (ui/paste-destination @rf-db/app-db
(:clip (store/entry id)) {})))))))
(deftest pasting-onto-what-you-copied-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-copied")]
(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/paste])
(is (= 2 (count (get-in (store/entry id) [:clip :symbols :main :nodes])))
"a symbol pasted with itself selected lands beside it, not refused as a cycle")))
(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")