@@ -58,6 +58,8 @@ pub struct NodeGraphMessageHandler {
5858 widgets : [ LayoutGroup ; 2 ] ,
5959 /// Used to add a transaction for the first node move when dragging.
6060 begin_dragging : bool ,
61+ /// Tracks whether nodes were duplicated via Alt-drag, so aborting undoes both the move and duplication.
62+ duplicated_in_drag : bool ,
6163 /// Used to prevent entering a nested network if the node is dragged after double clicking
6264 node_has_moved_in_drag : bool ,
6365 /// If dragging the selected nodes, this stores the starting position both in viewport and node graph coordinates,
@@ -780,7 +782,13 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
780782 if self . drag_start . is_some ( ) {
781783 self . drag_start = None ;
782784 self . select_if_not_dragged = None ;
783- responses. add ( DocumentMessage :: AbortTransaction ) ;
785+ if self . duplicated_in_drag {
786+ responses. add ( DocumentMessage :: AbortTransaction ) ;
787+ responses. add ( DocumentMessage :: Undo ) ;
788+ self . duplicated_in_drag = false ;
789+ } else {
790+ responses. add ( DocumentMessage :: AbortTransaction ) ;
791+ }
784792 responses. add ( NodeGraphMessage :: SelectedNodesSet {
785793 nodes : self . selection_before_pointer_down . clone ( ) ,
786794 } ) ;
@@ -1121,6 +1129,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
11211129 rubber_band : false ,
11221130 } ) ;
11231131 self . preview_on_mouse_up = None ;
1132+ self . duplicated_in_drag = true ;
11241133 }
11251134 }
11261135
@@ -1423,6 +1432,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
14231432
14241433 self . drag_start = None ;
14251434 self . begin_dragging = false ;
1435+ self . duplicated_in_drag = false ;
14261436 self . box_selection_start = None ;
14271437
14281438 self . wire_in_progress_from_connector = None ;
@@ -2810,6 +2820,7 @@ impl Default for NodeGraphMessageHandler {
28102820 widgets : [ LayoutGroup :: Row { widgets : Vec :: new ( ) } , LayoutGroup :: Row { widgets : Vec :: new ( ) } ] ,
28112821 drag_start : None ,
28122822 begin_dragging : false ,
2823+ duplicated_in_drag : false ,
28132824 node_has_moved_in_drag : false ,
28142825 shift_without_push : false ,
28152826 box_selection_start : None ,
@@ -2841,6 +2852,7 @@ impl PartialEq for NodeGraphMessageHandler {
28412852 && self . widgets == other. widgets
28422853 && self . drag_start == other. drag_start
28432854 && self . begin_dragging == other. begin_dragging
2855+ && self . duplicated_in_drag == other. duplicated_in_drag
28442856 && self . node_has_moved_in_drag == other. node_has_moved_in_drag
28452857 && self . box_selection_start == other. box_selection_start
28462858 && self . initial_disconnecting == other. initial_disconnecting
0 commit comments