Implement pasting nodes at cursor position in graph#4285
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements pasting nodes at the cursor's position in the node graph by calculating the offset between the cursor and the first absolutely positioned node, then shifting the pasted nodes accordingly. The feedback suggests avoiding the hardcoded grid size of 24. in favor of using the GRID_SIZE constant, and simplifying the reference handling of IVec2 by copying the option value.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 5/5
- In
editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs, hardcoding24.instead ofGRID_SIZEcan cause subtle grid alignment inconsistencies later if the shared constant changes, increasing maintenance risk rather than immediate runtime risk — replace the literal withGRID_SIZE as f64before merging to keep behavior centralized.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
!build (Run ID 28262192850) |
Wasm: 23.14 MB — JS: 0.44 MB — CSS: 0.09 MB — Fonts: 0.30 MB — Images: 0.09 MB — All Assets: 24.07 MB |
Closes #3798
This PR implements cursor-based paste by calculating the offset of the first selected node to be copied from the location of the most recent click. The following changes were added:
ipp.mouse.position) and the location of the first selected node.NodeGraphMessage::AddNodes), and then shift by the offset (NodeGraphMessage::ShiftSelectedNodesByAmount)One thing I'm not sure about is that one needs to actually click the desired paste location in order for
ipp.mouse.positionto update. Is there another something else tracking the cursor location?Here's two examples of copy and paste
First we select the Transform node at (-15,3) as well as the Path node.
Next, I click (-16,4) based on eyeballing the grid, then paste the nodes with Ctrl+v. The Transform node is pasted to (-16,4), while the pasted Path node maintains the relative distance to the Transform node, without any wires to the Transform node.
Next, I select Stroke -> Transform -> Path and then copy the nodes. Stroke is at (-22, 3).
Finally, I click at (-16, 8) then paste with Ctrl+v. We paste Stroke node at (-16, 8), and the other selected nodes are copied as well with wires maintained.