patch 9.1.1403: expansion of 'tabpanelopt' value adds wrong values

Problem:  expansion of 'tabpanelopt' value adds wrong values
          (Shane-XB-Qian, after v9.1.1391)
Solution: update tabpanelopt expansion function and expand only valid
          values (Hirohito Higashi)

related: #17263
closes: #17359

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/optionstr.c b/src/optionstr.c
index 553b55f..b286767 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -29,7 +29,9 @@
 static char *(p_briopt_values[]) = {"shift:", "min:", "sbr", "list:", "column:", NULL};
 #endif
 #if defined(FEAT_TABPANEL)
-static char *(p_tpl_values[]) = {"wrap", "align:", "columns:", "vert:", NULL};
+// Note: Keep this in sync with tabpanelopt_changed()
+static char *(p_tplo_values[]) = {"align:", "columns:", "vert", NULL};
+static char *(p_tplo_align_values[]) = {"left", "right", NULL};
 #endif
 #if defined(FEAT_DIFF)
 // Note: Keep this in sync with diffopt_changed()
@@ -3567,10 +3569,29 @@
     int
 expand_set_tabpanelopt(optexpand_T *args, int *numMatches, char_u ***matches)
 {
+    expand_T *xp = args->oe_xp;
+
+    if (xp->xp_pattern > args->oe_set_arg && *(xp->xp_pattern-1) == ':')
+    {
+	// Within "align:", we have a subgroup of possible options.
+	int align_len = (int)STRLEN("align:");
+	if (xp->xp_pattern - args->oe_set_arg >= align_len &&
+		STRNCMP(xp->xp_pattern - align_len, "align:", align_len) == 0)
+	{
+	    return expand_set_opt_string(
+		    args,
+		    p_tplo_align_values,
+		    ARRAY_LENGTH(p_tplo_align_values) - 1,
+		    numMatches,
+		    matches);
+	}
+	return FAIL;
+    }
+
     return expand_set_opt_string(
 	    args,
-	    p_tpl_values,
-	    ARRAY_LENGTH(p_tpl_values) - 1,
+	    p_tplo_values,
+	    ARRAY_LENGTH(p_tplo_values) - 1,
 	    numMatches,
 	    matches);
 }