patch 8.2.0845: text properties crossing lines not handled correctly

Problem:    Text properties crossing lines not handled correctly.
Solution:   When joining lines merge text properties if possible.
            (Axel Forsman, closes #5839, closes #5683)
diff --git a/src/memline.c b/src/memline.c
index 6d02119..3379a39 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -3420,7 +3420,6 @@
     int		done_del;
     int		done_this;
     textprop_T	prop_del;
-    textprop_T	prop_this;
     bhdr_T	*hp;
     DATA_BL	*dp;
     int		idx;
@@ -3451,7 +3450,8 @@
 		if (idx == 0)		// first line in block, text at the end
 		    line_size = dp->db_txt_end - line_start;
 		else
-		    line_size = ((dp->db_index[idx - 1]) & DB_INDEX_MASK) - line_start;
+		    line_size = ((dp->db_index[idx - 1]) & DB_INDEX_MASK)
+								  - line_start;
 		text = (char_u *)dp + line_start;
 		textlen = STRLEN(text) + 1;
 		if ((long)textlen >= line_size)
@@ -3466,24 +3466,24 @@
 	    }
 
 	    found = FALSE;
-	    for (done_this = 0; done_this < this_props_len; done_this += sizeof(textprop_T))
+	    for (done_this = 0; done_this < this_props_len;
+					       done_this += sizeof(textprop_T))
 	    {
-		mch_memmove(&prop_this, text + textlen + done_del, sizeof(textprop_T));
-		if (prop_del.tp_id == prop_this.tp_id
+		int	    flag = above ? TP_FLAG_CONT_NEXT
+							   : TP_FLAG_CONT_PREV;
+		textprop_T  prop_this;
+
+		mch_memmove(&prop_this, text + textlen + done_del,
+							   sizeof(textprop_T));
+		if ((prop_this.tp_flags & flag)
+			&& prop_del.tp_id == prop_this.tp_id
 			&& prop_del.tp_type == prop_this.tp_type)
 		{
-		    int flag = above ? TP_FLAG_CONT_NEXT : TP_FLAG_CONT_PREV;
-
 		    found = TRUE;
-		    if (prop_this.tp_flags & flag)
-		    {
-			prop_this.tp_flags &= ~flag;
-			mch_memmove(text + textlen + done_del, &prop_this, sizeof(textprop_T));
-		    }
-		    else if (above)
-			internal_error("text property above deleted line does not continue");
-		    else
-			internal_error("text property below deleted line does not continue");
+		    prop_this.tp_flags &= ~flag;
+		    mch_memmove(text + textlen + done_del, &prop_this,
+							   sizeof(textprop_T));
+		    break;
 		}
 	    }
 	    if (!found)