patch 9.0.0993: display errors when adding or removing text property type

Problem:    Display errors when adding or removing text property type.
Solution:   Perform a full redraw.  Only use text properties for which the
            type is defined. (closes #11655)
diff --git a/src/textprop.c b/src/textprop.c
index 789ab8f..c1fc34e 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -653,7 +653,7 @@
     for (i = 0; i < count; ++i)
     {
 	mch_memmove(&prop, props + i * sizeof(prop), sizeof(prop));
-	if (prop.tp_col == MAXCOL)
+	if (prop.tp_col == MAXCOL && text_prop_type_valid(buf, &prop))
 	{
 	    if ((prop.tp_flags & TP_FLAG_ALIGN_BELOW)
 		    || (next_right_goes_below
@@ -697,7 +697,8 @@
 	// previous line, or when not in the last line and it is virtual text
 	// after the line.
 	if ((only_starting && (prop.tp_flags & TP_FLAG_CONT_PREV))
-		|| (!last_line && prop.tp_col == MAXCOL))
+		|| (!last_line && prop.tp_col == MAXCOL)
+		|| !text_prop_type_valid(curbuf, &prop))
 	    --result;
     }
     return result;
@@ -801,20 +802,24 @@
  * Returns FAIL when not found.
  */
     int
-find_visible_prop(win_T *wp, int type_id, int id, textprop_T *prop,
-							  linenr_T *found_lnum)
+find_visible_prop(
+	win_T	    *wp,
+	int	    type_id,
+	int	    id,
+	textprop_T  *prop,
+	linenr_T    *found_lnum)
 {
-    linenr_T		lnum;
-    char_u		*props;
-    int			count;
-    int			i;
+    // return when "type_id" no longer exists
+    if (text_prop_type_by_id(wp->w_buffer, type_id) == NULL)
+	return FAIL;
 
     // w_botline may not have been updated yet.
     validate_botline_win(wp);
-    for (lnum = wp->w_topline; lnum < wp->w_botline; ++lnum)
+    for (linenr_T lnum = wp->w_topline; lnum < wp->w_botline; ++lnum)
     {
-	count = get_text_props(wp->w_buffer, lnum, &props, FALSE);
-	for (i = 0; i < count; ++i)
+	char_u	*props;
+	int	count = get_text_props(wp->w_buffer, lnum, &props, FALSE);
+	for (int i = 0; i < count; ++i)
 	{
 	    mch_memmove(prop, props + i * sizeof(textprop_T),
 							   sizeof(textprop_T));
@@ -986,6 +991,15 @@
 }
 
 /*
+ * Return TRUE if "prop" is a valid text property type.
+ */
+    int
+text_prop_type_valid(buf_T *buf, textprop_T *prop)
+{
+    return text_prop_type_by_id(buf, prop->tp_type) != NULL;
+}
+
+/*
  * prop_clear({lnum} [, {lnum_end} [, {bufnr}]])
  */
     void
@@ -1745,7 +1759,7 @@
     name = tv_get_string(&argvars[0]);
     if (*name == NUL)
     {
-	emsg(_(e_invalid_argument));
+	semsg(_(e_invalid_argument_str), "\"\"");
 	return;
     }
 
@@ -1898,7 +1912,7 @@
     name = tv_get_string(&argvars[0]);
     if (*name == NUL)
     {
-	emsg(_(e_invalid_argument));
+	semsg(_(e_invalid_argument_str), "\"\"");
 	return;
     }
 
@@ -1926,6 +1940,10 @@
 	}
 	hash_remove(ht, hi, "prop type delete");
 	vim_free(prop);
+
+	// currently visibile text properties will disappear
+	redraw_all_later(UPD_CLEAR);
+	changed_window_setting_buf(buf == NULL ? curbuf : buf);
     }
 }
 
@@ -1945,7 +1963,7 @@
     name = tv_get_string(&argvars[0]);
     if (*name == NUL)
     {
-	emsg(_(e_invalid_argument));
+	semsg(_(e_invalid_argument_str), "\"\"");
 	return;
     }
     if (rettv_dict_alloc(rettv) == OK)