Repository: godotengine/godot
File: editor/plugins/path_2d_editor_plugin.cpp (C++)

Code before:
		curve_edit_curve->set_pressed(false);
		curve_del->set_pressed(true);
	} else if (p_mode == ACTION_CLOSE) {
		//?

		if (!node->get_curve().is_valid()) {
			return;
		}
		if (node->get_curve()->get_point_count() < 3) {
			return;
		}

		Vector2 begin = node->get_curve()->get_point_position(0);
		Vector2 end = node->get_curve()->get_point_position(node->get_curve()->get_point_count() - 1);
		if (begin.is_equal_approx(end)) {
			return;
		}

		EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
		undo_redo->create_action(TTR("Remove Point from Curve"));
		undo_redo->add_do_method(node->get_curve().ptr(), "add_point", begin);
		undo_redo->add_undo_method(node->get_curve().ptr(), "remove_point", node->get_curve()->get_point_count());
		undo_redo->add_do_method(canvas_item_editor, "update_viewport");
		undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
		undo_redo->commit_action();
		return;
	}

	mode = Mode(p_mode);
}

void Path2DEditor::_handle_option_pressed(int p_option) {
	PopupMenu *pm;
	pm = handle_menu->get_popup();

	switch (p_option) {
		case HANDLE_OPTION_ANGLE: {
			bool is_checked = pm->is_item_checked(HANDLE_OPTION_ANGLE);
			mirror_handle_angle = !is_checked;
			pm->set_item_checked(HANDLE_OPTION_ANGLE, mirror_handle_angle);
			pm->set_item_disabled(HANDLE_OPTION_LENGTH, !mirror_handle_angle);
		} break;
		case HANDLE_OPTION_LENGTH: {
			bool is_checked = pm->is_item_checked(HANDLE_OPTION_LENGTH);
			mirror_handle_length = !is_checked;
			pm->set_item_checked(HANDLE_OPTION_LENGTH, mirror_handle_length);
		} break;
	}
}

Path2DEditor::Path2DEditor() {

Review comment (suggestion):
```suggestion
			undo_redo->create_action(TTR("Clear Curve Points"), node);
```
`create_action_for_history()` is needed only for very specific cases. Normally you can use the context argument in `create_action()`.

Code after:
		curve_del->set_pressed(false);
	} else if (p_mode == MODE_DELETE) {
		curve_create->set_pressed(false);
		curve_edit->set_pressed(false);
		curve_edit_curve->set_pressed(false);
		curve_del->set_pressed(true);
	} else if (p_mode == MODE_CLOSE) {
		if (node->get_curve().is_null()) {
			return;
		}
		if (node->get_curve()->get_point_count() < 3) {
			return;
		}
		Vector2 begin = node->get_curve()->get_point_position(0);
		Vector2 end = node->get_curve()->get_point_position(node->get_curve()->get_point_count() - 1);

		if (begin.is_equal_approx(end)) {
			return;
		}
		EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();

		undo_redo->create_action(TTR("Close the Curve"));
		undo_redo->add_do_method(node->get_curve().ptr(), "add_point", begin);
		undo_redo->add_undo_method(node->get_curve().ptr(), "remove_point", node->get_curve()->get_point_count());
		undo_redo->add_do_method(canvas_item_editor, "update_viewport");
		undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
		undo_redo->commit_action();
		return;
	} else if (p_mode == MODE_CLEAR_POINTS) {
		if (node->get_curve().is_null()) {
			return;
		}
		if (node->get_curve()->get_point_count() == 0) {
			return;
		}
		EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
		PackedVector2Array points = node->get_curve()->get_points().duplicate();

		undo_redo->create_action(TTR("Clear Curve Points"), UndoRedo::MERGE_DISABLE, node);
		undo_redo->add_do_method(this, "_clear_curve_points", node);
		undo_redo->add_undo_method(this, "_restore_curve_points", node, points);
		undo_redo->add_do_method(canvas_item_editor, "update_viewport");
		undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
		undo_redo->commit_action();
		return;
	}
	mode = Mode(p_mode);
}

void Path2DEditor::_handle_option_pressed(int p_option) {
	PopupMenu *pm;