patch 8.2.5013: after text formatting cursor may be in an invalid position

Problem:    After text formatting the cursor may be in an invalid position.
Solution:   Correct the cursor position after formatting.
diff --git a/src/textformat.c b/src/textformat.c
index 7e32c1c..5ba2f17 100644
--- a/src/textformat.c
+++ b/src/textformat.c
@@ -870,6 +870,9 @@
     {
 	curwin->w_cursor = saved_cursor;
 	saved_cursor.lnum = 0;
+
+	// formatting may have made the cursor position invalid
+	check_cursor();
     }
 
     if (oap->is_VIsual)