From 6cf54d06beb279f7dfa024e2898ac62cafa10e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fortin?= Date: Sat, 25 Sep 2021 13:22:10 -0400 Subject: [PATCH] add missing undo on CloseCurve --- editor/plugins/path_editor_plugin.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp index 0e9d3a4d044..43fc9a87549 100644 --- a/editor/plugins/path_editor_plugin.cpp +++ b/editor/plugins/path_editor_plugin.cpp @@ -503,7 +503,14 @@ void PathEditorPlugin::_close_curve() { if (c->get_point_count() < 2) { return; } - c->add_point(c->get_point_position(0), c->get_point_in(0), c->get_point_out(0)); + if (c->get_point_position(0) == c->get_point_position(c->get_point_count() - 1)) { + return; + } + UndoRedo *ur = editor->get_undo_redo(); + ur->create_action(TTR("Close Curve")); + ur->add_do_method(c.ptr(), "add_point", c->get_point_position(0), c->get_point_in(0), c->get_point_out(0), -1); + ur->add_undo_method(c.ptr(), "remove_point", c->get_point_count()); + ur->commit_action(); } void PathEditorPlugin::_handle_option_pressed(int p_option) {