@@ -2308,7 +2308,6 @@ void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) {
23082308 ERR_FAIL_NULL (new_parent);
23092309
23102310 List<Node *> selection = editor_selection->get_selected_node_list ();
2311- List<Node *> full_selection = editor_selection->get_full_selected_node_list ();
23122311
23132312 if (selection.is_empty ()) {
23142313 return ; // Nothing to reparent.
@@ -2321,10 +2320,6 @@ void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) {
23212320 }
23222321
23232322 _do_reparent (new_parent, -1 , nodes, p_keep_global_xform);
2324-
2325- for (Node *E : full_selection) {
2326- editor_selection->add_node (E);
2327- }
23282323}
23292324
23302325void SceneTreeDock::_do_reparent (Node *p_new_parent, int p_position_in_parent, Vector<Node *> p_nodes, bool p_keep_global_xform) {
@@ -2517,12 +2512,20 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
25172512
25182513 perform_node_renames (nullptr , &path_renames);
25192514
2520- undo_redo->commit_action ();
2515+ undo_redo->add_do_method (editor_selection, " clear" );
2516+ undo_redo->add_undo_method (editor_selection, " clear" );
2517+ List<Node *> full_selection = editor_selection->get_full_selected_node_list ();
2518+ for (Node *E : full_selection) {
2519+ undo_redo->add_do_method (editor_selection, " add_node" , E);
2520+ undo_redo->add_undo_method (editor_selection, " add_node" , E);
2521+ }
25212522
25222523 if (need_edit) {
25232524 EditorNode::get_singleton ()->edit_current ();
25242525 editor_selection->clear ();
25252526 }
2527+
2528+ undo_redo->commit_action ();
25262529}
25272530
25282531void SceneTreeDock::_script_created (Ref<Script> p_script) {
@@ -3661,7 +3664,6 @@ void SceneTreeDock::_nodes_dragged(const Array &p_nodes, NodePath p_to, int p_ty
36613664 }
36623665
36633666 List<Node *> selection = editor_selection->get_selected_node_list ();
3664- List<Node *> full_selection = editor_selection->get_full_selected_node_list ();
36653667
36663668 if (selection.is_empty ()) {
36673669 return ; // nothing to reparent
@@ -3681,10 +3683,6 @@ void SceneTreeDock::_nodes_dragged(const Array &p_nodes, NodePath p_to, int p_ty
36813683
36823684 _normalize_drop (to_node, to_pos, p_type);
36833685 _do_reparent (to_node, to_pos, nodes, !Input::get_singleton ()->is_key_pressed (Key::SHIFT));
3684-
3685- for (Node *E : full_selection) {
3686- editor_selection->add_node (E);
3687- }
36883686}
36893687
36903688void SceneTreeDock::_add_children_to_popup (Object *p_obj, int p_depth) {
0 commit comments