]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0766: quick_tab entries for empty letters point to the wrong index v9.2.0766
authorIllia Bobyr <illia.bobyr@gmail.com>
Thu, 2 Jul 2026 18:28:59 +0000 (18:28 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 2 Jul 2026 18:28:59 +0000 (18:28 +0000)
Problem:  Letters with no options (like "y" and "z") have their
          quick_tab entry left at 0, so lookups for those letters start
          scanning at options[0] instead of failing fast.
Solution: Set entries for letters with no option names to the last-option
          index, so such lookups stop immediately (Illia Bobyr)

closes: #20684

Signed-off-by: Illia Bobyr <illia.bobyr@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/option.c
src/version.c

index d15cc3f3c5481a0fdc92017f241fbe53c276c6fa..9d291d1809b197dae92be33c59d4183bd6d47118 100644 (file)
@@ -5587,9 +5587,19 @@ findoption(char_u *arg)
     // letter.  There are 26 letters, plus the first "t_" option.
     if (quick_tab[1] == 0)
     {
+       // Make sure we do not leave any entries uninitialized, even if we have
+       // no options that start with a particular letter.
+       int last_opt_idx;
+       for (last_opt_idx = 0; options[last_opt_idx].fullname != NULL;
+               last_opt_idx++)
+           ;
+       for (int tab_idx = 1; tab_idx < 27; tab_idx++)
+           quick_tab[tab_idx] = last_opt_idx;
+
        p = options[0].fullname;
-       for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
+       for (opt_idx = 1; opt_idx < last_opt_idx; opt_idx++)
        {
+           s = options[opt_idx].fullname;
            if (s[0] != p[0])
            {
                if (s[0] == 't' && s[1] == '_')
index dd14dedba2aa772a7618a7182033713b7d5e6aae..2c531eb5bc45dd08989810238986f6f1a9ba260b 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    766,
 /**/
     765,
 /**/