Repository: godotengine/godot
File: editor/scene/sprite_frames_editor_plugin.cpp (C++)

Code before:
		return;
	}

	String new_name = _generate_unique_animation_name(clipboard_anim->animation_name);
	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(TTR("Paste Animation"), UndoRedo::MERGE_DISABLE, EditorNode::get_singleton()->get_edited_scene());
	undo_redo->add_do_method(frames.ptr(), "add_animation", new_name);
	undo_redo->add_undo_method(frames.ptr(), "remove_animation", new_name);
	undo_redo->add_do_method(frames.ptr(), "set_animation_speed", new_name, clipboard_anim->animation_speed);
	undo_redo->add_do_method(frames.ptr(), "set_animation_loop", new_name, clipboard_anim->animation_loop);

	for (ClipboardSpriteFrames::Frame &frame : clipboard_anim->animation_frames) {
		undo_redo->add_do_method(frames.ptr(), "add_frame", new_name, frame.texture, frame.duration);
	}

	undo_redo->add_do_method(this, "_select_animation", new_name);
	undo_redo->add_undo_method(this, "_select_animation", edited_anim);
	undo_redo->add_do_method(this, "_update_library");
	undo_redo->add_undo_method(this, "_update_library");
	undo_redo->commit_action();
}

void SpriteFramesEditor::_animation_remove() {
	if (updating) {
		return;
	}

	if (!frames->has_animation(edited_anim)) {
		return;
	}

	delete_dialog->set_text(TTR("Delete Animation?"));
	delete_dialog->popup_centered();
}

void SpriteFramesEditor::_animation_remove_confirmed() {
	_animation_remove_undo_redo(TTR("Remove Animation"), nullptr);
}

void SpriteFramesEditor::_animation_search_text_changed(const String &p_text) {
	_update_library();
}

void SpriteFramesEditor::_animation_loop_changed() {
	if (updating) {
		return;
	}

	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(TTR("Change Animation Loop"), UndoRedo::MERGE_DISABLE, frames.ptr());
	undo_redo->add_do_method(frames.ptr(), "set_animation_loop", edited_anim, anim_loop->is_pressed());

Review comment (suggestion):
```suggestion

void SpriteFramesEditor::_animation_paste() {
```

Code after:
	animations->grab_focus();
}

void SpriteFramesEditor::_animation_cut() {
	if (!frames->has_animation(edited_anim)) {
		return;
	}

	// Copy animation to clipboard.
	Ref<ClipboardAnimation> clipboard_anim = ClipboardAnimation::from_sprite_frames(frames, edited_anim);
	EditorSettings::get_singleton()->set_resource_clipboard(clipboard_anim);

	// Remove animation with undo/redo (no confirmation dialog).
	_animation_remove_undo_redo(TTR("Cut Animation"), &clipboard_anim->frames);
}

void SpriteFramesEditor::_animation_copy() {
	if (!frames->has_animation(edited_anim)) {
		return;
	}

	Ref<ClipboardAnimation> clipboard_anim = ClipboardAnimation::from_sprite_frames(frames, edited_anim);
	EditorSettings::get_singleton()->set_resource_clipboard(clipboard_anim);
}

void SpriteFramesEditor::_animation_paste() {
	if (updating) {
		return;
	}

	Ref<ClipboardAnimation> clipboard_anim = EditorSettings::get_singleton()->get_resource_clipboard();
	if (clipboard_anim.is_null()) {
		return;
	}

	String new_name = _generate_unique_animation_name(clipboard_anim->name);
	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(TTR("Paste Animation"), UndoRedo::MERGE_DISABLE, EditorNode::get_singleton()->get_edited_scene());
	undo_redo->add_do_method(frames.ptr(), "add_animation", new_name);
	undo_redo->add_undo_method(frames.ptr(), "remove_animation", new_name);
	undo_redo->add_do_method(frames.ptr(), "set_animation_speed", new_name, clipboard_anim->speed);
	undo_redo->add_do_method(frames.ptr(), "set_animation_loop", new_name, clipboard_anim->loop);

	for (ClipboardSpriteFrames::Frame &frame : clipboard_anim->frames) {
		undo_redo->add_do_method(frames.ptr(), "add_frame", new_name, frame.texture, frame.duration);
	}

	undo_redo->add_do_method(this, "_select_animation", new_name);
	undo_redo->add_undo_method(this, "_select_animation", edited_anim);
	undo_redo->add_do_method(this, "_update_library");
	undo_redo->add_undo_method(this, "_update_library");