Repository: godotengine/godot
File: editor/docks/scene_tree_dock.cpp (C++)

Code before:
								}
							}
						}

						// key.get_path() of p_renames is like:
						//  /root/@EditorNode@18033/@Panel@14/.../Scene/TheOldName
						// value of p_renames is like:
						//  /root/@EditorNode@18033/@Panel@14/.../Scene/TheNewName
						for (const KeyValue<Node *, NodePath> &rename : *p_renames) {
							NodePath old_path = rename.key->get_path();
							NodePath new_path = rename.value;
							Vector<StringName> rel_path = old_path.rel_path_to(new_path).get_names();

							StringName old_node_name = rename.key->get_name();
							StringName new_node_name = rel_path[rel_path.size() - 1];

							anim->editor_set_group_folded(new_node_name, anim->editor_is_group_folded(old_node_name));
							anim->editor_set_group_folded(old_node_name, false);
						}

						if (!anim->get_path().is_resource_file()) {
							EditorNode::get_singleton()->get_editor_folding().save_scene_folding(
									EditorNode::get_singleton()->get_edited_scene(),
									EditorNode::get_singleton()->get_edited_scene()->get_scene_file_path());
						} else {
							EditorNode::get_singleton()->get_editor_folding().save_resource_folding(
									anim,
									anim->get_path());
						}
					}
				}
			}
		}
	}

	// Renaming node paths used in node properties.
	_check_object_properties_recursive(p_base, p_base, p_renames);

	for (int i = 0; i < p_base->get_child_count(); i++) {
		perform_node_renames(p_base->get_child(i), p_renames, r_rem_anims);
	}
}

void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) {
	HashMap<Node *, NodePath> path_renames;

	Vector<StringName> base_path;
	Node *n = p_node->get_parent();
	while (n) {
		base_path.push_back(n->get_name());
		n = n->get_parent();

Review comment (suggestion):
```suggestion
							EditorNode::get_editor_folding().save_resource_folding(
```

Code after:
									undo_redo->add_undo_method(anim.ptr(), "track_set_interpolation_type", idx, anim->track_get_interpolation_type(i));
									for (int j = 0; j < anim->track_get_key_count(i); j++) {
										undo_redo->add_undo_method(anim.ptr(), "track_insert_key", idx, anim->track_get_key_time(i, j), anim->track_get_key_value(i, j), anim->track_get_key_transition(i, j));
									}

									ran.erase(i); //byebye channel

								} else {
									//will be renamed
									NodePath rel_path = new_root_path.rel_path_to(found_path->value);

									NodePath new_path = NodePath(rel_path.get_names(), track_np.get_subnames(), false);
									if (new_path == track_np) {
										continue; //bleh
									}
									undo_redo->add_do_method(anim.ptr(), "track_set_path", i, new_path);
									undo_redo->add_undo_method(anim.ptr(), "track_set_path", i, track_np);
								}
							}
						}

						// key.get_path() of p_renames is like:
						//  /root/@EditorNode@18033/@Panel@14/.../Scene/TheOldName
						// value of p_renames is like:
						//  /root/@EditorNode@18033/@Panel@14/.../Scene/TheNewName
						for (const KeyValue<Node *, NodePath> &rename : *p_renames) {
							NodePath old_path = rename.key->get_path();
							NodePath new_path = rename.value;
							Vector<StringName> rel_path = old_path.rel_path_to(new_path).get_names();

							StringName old_node_name = rename.key->get_name();
							StringName new_node_name = rel_path[rel_path.size() - 1];

							anim->editor_set_group_folded(new_node_name, anim->editor_is_group_folded(old_node_name));
							anim->editor_set_group_folded(old_node_name, false);
						}

						if (!anim->get_path().is_resource_file()) {
							EditorNode::get_editor_folding().save_scene_folding(
									EditorNode::get_singleton()->get_edited_scene(),
									EditorNode::get_singleton()->get_edited_scene()->get_scene_file_path());
						} else {
							EditorNode::get_editor_folding().save_resource_folding(
									anim,
									anim->get_path());
						}
					}
				}
			}
		}
	}