]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1403: expansion of 'tabpanelopt' value adds wrong values v9.1.1403
authorHirohito Higashi <h.east.727@gmail.com>
Thu, 22 May 2025 20:41:05 +0000 (22:41 +0200)
committerChristian Brabandt <cb@256bit.org>
Thu, 22 May 2025 20:41:05 +0000 (22:41 +0200)
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>
src/optiondefs.h
src/optionstr.c
src/tabpanel.c
src/version.c

index cb4376c716c138741bee4ca6f136526d888c5b75..5d9f388aa22840cbb0f1ddc35fc63a84f1d68ec4 100644 (file)
@@ -2537,7 +2537,8 @@ static struct vimoption options[] =
     {"tabpanel",  "tpl",    P_STRING|P_VI_DEF|P_RALL,
                            (char_u *)&p_tpl, PV_NONE, NULL, NULL,
                            {(char_u *)"", (char_u *)0L} SCTX_INIT},
-    {"tabpanelopt","tplo",  P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
+    {"tabpanelopt","tplo",  P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_COLON
+                                                                   |P_NODUP,
                            (char_u *)&p_tplo, PV_NONE, did_set_tabpanelopt,
                            expand_set_tabpanelopt,
                            {(char_u *)"", (char_u *)0L}
index 553b55f687dfc2a5ec0e6defff39677d1cdafda0..b286767e3f686b84db403662f4dc8d33b753d483 100644 (file)
@@ -29,7 +29,9 @@ static char *(p_bo_values[]) = {"all", "backspace", "cursor", "complete",
 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 @@ did_set_tabpanelopt(optset_T *args)
     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);
 }
index fb5a957a3e7f1baa99e39e8b65e63f7b510baadc..81e2c0c079bddd6cf87fe866e009632dc4540d4f 100644 (file)
@@ -64,15 +64,21 @@ tabpanelopt_changed(void)
     p = p_tplo;
     while (*p != NUL)
     {
-       if (STRNCMP(p, "align:left", 10) == 0)
+       if (STRNCMP(p, "align:", 6) == 0)
        {
-           p += 10;
-           new_align = ALIGN_LEFT;
-       }
-       else if (STRNCMP(p, "align:right", 11) == 0)
-       {
-           p += 11;
-           new_align = ALIGN_RIGHT;
+           p += 6;
+           if (STRNCMP(p, "left", 4) == 0)
+           {
+               p += 4;
+               new_align = ALIGN_LEFT;
+           }
+           else if (STRNCMP(p, "right", 5) == 0)
+           {
+               p += 5;
+               new_align = ALIGN_RIGHT;
+           }
+           else
+               return FAIL;
        }
        else if (STRNCMP(p, "columns:", 8) == 0 && VIM_ISDIGIT(p[8]))
        {
index 1f5cd0222e0228c8f82d94a1b5d9e6891a2e2ea1..f94dbe3e431f3a7b31e0447ec69d2bcf6921feb9 100644 (file)
@@ -709,6 +709,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1403,
 /**/
     1402,
 /**/