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

Code before:
			action_point = insertion_point + 1;
			moving_from = curve->get_point_position(action_point);
			moving_screen_from = gpoint2;

			canvas_item_editor->update_viewport();

			on_edge = false;

			return true;
		}

		// Check for point movement completion.
		if (!mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT && action != ACTION_NONE) {
			Ref<Curve2D> curve = node->get_curve();

			EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
			Vector2 new_pos = moving_from + xform.affine_inverse().basis_xform(gpoint - moving_screen_from);
			switch (action) {
				case ACTION_NONE:
					// N/A, handled in above condition.
					break;

				case ACTION_MOVING_POINT: {
					undo_redo->create_action(TTR("Move Point in Curve"));
					undo_redo->add_do_method(curve.ptr(), "set_point_position", action_point, cpoint);
					undo_redo->add_undo_method(curve.ptr(), "set_point_position", action_point, moving_from);
					undo_redo->add_do_method(canvas_item_editor, "update_viewport");
					undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
					undo_redo->commit_action();

				} break;

				case ACTION_MOVING_IN: {
					undo_redo->create_action(TTR("Move In-Control in Curve"));
					undo_redo->add_do_method(curve.ptr(), "set_point_in", action_point, new_pos);
					undo_redo->add_undo_method(curve.ptr(), "set_point_in", action_point, moving_from);

					if (mirror_handle_angle) {
						undo_redo->add_do_method(curve.ptr(), "set_point_out", action_point, mirror_handle_length ? -new_pos : (-new_pos.normalized() * orig_out_length));
						undo_redo->add_undo_method(curve.ptr(), "set_point_out", action_point, mirror_handle_length ? -moving_from : (-moving_from.normalized() * orig_out_length));
					}
					undo_redo->add_do_method(canvas_item_editor, "update_viewport");
					undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
					undo_redo->commit_action();

				} break;

				case ACTION_MOVING_OUT: {
					undo_redo->create_action(TTR("Move Out-Control in Curve"));
					undo_redo->add_do_method(curve.ptr(), "set_point_out", action_point, new_pos);
					undo_redo->add_undo_method(curve.ptr(), "set_point_out", action_point, moving_from);

Review comment (suggestion):
I think here the use of nested actions makes it a bit harder to read especially since we are already checking the exact condition for which we should not be creating this action so I would replace those lines with 
```
	if (action == ACTION_MOVING_POINT) {
		undo_redo->create_action(TTR("Move Point in Curve"));
		undo_redo->add_undo_method(curve.ptr(), "set_point_position", action_point, moving_from);
	}
	undo_redo->add_do_method(curve.ptr(), "set_point_position", action_point, cpoint);
	undo_redo->add_do_method(canvas_item_editor, "update_viewport");
	undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
	undo_redo->commit_action(false);
```

And remove the `update_viewport` on line 163-164 and 201-202 as it is better to have them just in one place instead of three

Code after:
			moving_screen_from = gpoint2;

			canvas_item_editor->update_viewport();

			on_edge = false;

			return true;
		}

		// Check for point movement completion.
		if (!mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT && action != ACTION_NONE) {
			Ref<Curve2D> curve = node->get_curve();

			EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
			Vector2 new_pos = moving_from + xform.affine_inverse().basis_xform(gpoint - moving_screen_from);
			switch (action) {
				case ACTION_NONE:
					// N/A, handled in above condition.
					break;

				case ACTION_MOVING_POINT:
				case ACTION_MOVING_NEW_POINT: {
					if (action == ACTION_MOVING_POINT) {
						undo_redo->create_action(TTR("Move Point in Curve"));
						undo_redo->add_undo_method(curve.ptr(), "set_point_position", action_point, moving_from);
					}
					undo_redo->add_do_method(curve.ptr(), "set_point_position", action_point, cpoint);
					undo_redo->add_do_method(canvas_item_editor, "update_viewport");
					undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
					undo_redo->commit_action(false);

				} break;

				case ACTION_MOVING_IN: {
					undo_redo->create_action(TTR("Move In-Control in Curve"));
					undo_redo->add_do_method(curve.ptr(), "set_point_in", action_point, new_pos);
					undo_redo->add_undo_method(curve.ptr(), "set_point_in", action_point, moving_from);

					if (mirror_handle_angle) {
						undo_redo->add_do_method(curve.ptr(), "set_point_out", action_point, mirror_handle_length ? -new_pos : (-new_pos.normalized() * orig_out_length));
						undo_redo->add_undo_method(curve.ptr(), "set_point_out", action_point, mirror_handle_length ? -moving_from : (-moving_from.normalized() * orig_out_length));
					}
					undo_redo->add_do_method(canvas_item_editor, "update_viewport");
					undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
					undo_redo->commit_action();

				} break;

				case ACTION_MOVING_OUT: {
					undo_redo->create_action(TTR("Move Out-Control in Curve"));
					undo_redo->add_do_method(curve.ptr(), "set_point_out", action_point, new_pos);