0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 9.0.2154: The option[] array is not sorted

Problem:  The options[] array is not sorted alphabetically.
Solution: Sort it alphabetically.  Add a test.  Avoid unnecessary loop
          iterations in findoption().

closes: #13648

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2023-12-08 21:34:31 +01:00
committed by Christian Brabandt
parent ff0baca865
commit f48558e10a
4 changed files with 91 additions and 84 deletions

View File

@@ -4933,11 +4933,13 @@ findoption(char_u *arg)
opt_idx = quick_tab[26];
else
opt_idx = quick_tab[CharOrdLow(arg[0])];
for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
for (; (s = options[opt_idx].fullname) != NULL && s[0] == arg[0]; opt_idx++)
{
if (STRCMP(arg, s) == 0) // match full name
break;
}
if (s != NULL && s[0] != arg[0])
s = NULL;
if (s == NULL && !is_term_opt)
{
opt_idx = quick_tab[CharOrdLow(arg[0])];

View File

@@ -341,20 +341,6 @@ static struct vimoption options[] =
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)FALSE, (char_u *)FALSE}
SCTX_INIT},
{"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
#ifdef FEAT_ARABIC
(char_u *)VAR_WIN, PV_ARAB, did_set_arabic, NULL,
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
#endif
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
#ifdef FEAT_ARABIC
(char_u *)&p_arshape, PV_NONE, NULL, NULL,
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
#endif
{(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
{"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
#ifdef FEAT_RIGHTLEFT
(char_u *)&p_ari, PV_NONE, NULL, NULL,
@@ -369,6 +355,20 @@ static struct vimoption options[] =
(char_u *)&p_ambw, PV_NONE, did_set_ambiwidth, expand_set_ambiwidth,
{(char_u *)"single", (char_u *)0L}
SCTX_INIT},
{"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
#ifdef FEAT_ARABIC
(char_u *)VAR_WIN, PV_ARAB, did_set_arabic, NULL,
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
#endif
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
#ifdef FEAT_ARABIC
(char_u *)&p_arshape, PV_NONE, NULL, NULL,
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
#endif
{(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
{"autochdir", "acd", P_BOOL|P_VI_DEF,
#ifdef FEAT_AUTOCHDIR
(char_u *)&p_acd, PV_NONE, did_set_autochdir, NULL,
@@ -376,15 +376,6 @@ static struct vimoption options[] =
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)0L, (char_u *)0L}
#endif
SCTX_INIT},
{"autoshelldir", "asd", P_BOOL|P_VI_DEF,
#ifdef FEAT_AUTOSHELLDIR
(char_u *)&p_asd, PV_NONE, NULL, NULL,
{(char_u *)FALSE, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)0L, (char_u *)0L}
#endif
SCTX_INIT},
{"autoindent", "ai", P_BOOL|P_VI_DEF,
@@ -396,6 +387,15 @@ static struct vimoption options[] =
{"autoread", "ar", P_BOOL|P_VI_DEF,
(char_u *)&p_ar, PV_AR, NULL, NULL,
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"autoshelldir", "asd", P_BOOL|P_VI_DEF,
#ifdef FEAT_AUTOSHELLDIR
(char_u *)&p_asd, PV_NONE, NULL, NULL,
{(char_u *)FALSE, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)0L, (char_u *)0L}
#endif
SCTX_INIT},
{"autowrite", "aw", P_BOOL|P_VI_DEF,
(char_u *)&p_aw, PV_NONE, NULL, NULL,
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
@@ -643,23 +643,6 @@ static struct vimoption options[] =
(char_u *)&p_cpt, PV_CPT, did_set_complete, expand_set_complete,
{(char_u *)".,w,b,u,t,i", (char_u *)0L}
SCTX_INIT},
{"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF|P_FLAGLIST,
#ifdef FEAT_CONCEAL
(char_u *)VAR_WIN, PV_COCU, did_set_concealcursor, expand_set_concealcursor,
{(char_u *)"", (char_u *)NULL}
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)NULL, (char_u *)0L}
#endif
SCTX_INIT},
{"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
#ifdef FEAT_CONCEAL
(char_u *)VAR_WIN, PV_COLE, did_set_conceallevel, NULL,
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
#endif
{(char_u *)0L, (char_u *)0L}
SCTX_INIT},
{"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE|P_FUNC,
#ifdef FEAT_COMPL_FUNC
(char_u *)&p_cfu, PV_CFU, did_set_completefunc, NULL,
@@ -691,6 +674,23 @@ static struct vimoption options[] =
{(char_u *)0L, (char_u *)0L}
#endif
SCTX_INIT},
{"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF|P_FLAGLIST,
#ifdef FEAT_CONCEAL
(char_u *)VAR_WIN, PV_COCU, did_set_concealcursor, expand_set_concealcursor,
{(char_u *)"", (char_u *)NULL}
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)NULL, (char_u *)0L}
#endif
SCTX_INIT},
{"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
#ifdef FEAT_CONCEAL
(char_u *)VAR_WIN, PV_COLE, did_set_conceallevel, NULL,
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
#endif
{(char_u *)0L, (char_u *)0L}
SCTX_INIT},
{"confirm", "cf", P_BOOL|P_VI_DEF,
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
(char_u *)&p_confirm, PV_NONE, NULL, NULL,
@@ -1091,14 +1091,14 @@ static struct vimoption options[] =
{(char_u *)0L, (char_u *)0L}
#endif
SCTX_INIT},
{"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
(char_u *)&p_fo, PV_FO, did_set_formatoptions, expand_set_formatoptions,
{(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
SCTX_INIT},
{"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
(char_u *)&p_flp, PV_FLP, NULL, NULL,
{(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
(char_u *)0L} SCTX_INIT},
{"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
(char_u *)&p_fo, PV_FO, did_set_formatoptions, expand_set_formatoptions,
{(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
SCTX_INIT},
{"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
(char_u *)&p_fp, PV_FP, NULL, NULL,
{(char_u *)"", (char_u *)0L} SCTX_INIT},
@@ -1203,6 +1203,14 @@ static struct vimoption options[] =
SCTX_INIT},
{"guiheadroom", "ghr", P_NUM|P_VI_DEF,
#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
(char_u *)&p_ghr, PV_NONE, NULL, NULL,
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
#endif
{(char_u *)50L, (char_u *)0L} SCTX_INIT},
{"guiligatures", "gli", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
#if defined(FEAT_GUI_GTK)
(char_u *)&p_guiligatures, PV_NONE,
@@ -1214,14 +1222,6 @@ static struct vimoption options[] =
#endif
SCTX_INIT},
{"guiheadroom", "ghr", P_NUM|P_VI_DEF,
#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
(char_u *)&p_ghr, PV_NONE, NULL, NULL,
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
#endif
{(char_u *)50L, (char_u *)0L} SCTX_INIT},
{"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
#if defined(FEAT_GUI)
(char_u *)&p_go, PV_NONE, did_set_guioptions, expand_set_guioptions,
@@ -1997,24 +1997,6 @@ static struct vimoption options[] =
{"pumwidth", "pw", P_NUM|P_VI_DEF,
(char_u *)&p_pw, PV_NONE, NULL, NULL,
{(char_u *)15L, (char_u *)15L} SCTX_INIT},
{"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
#if defined(DYNAMIC_PYTHON3)
(char_u *)&p_py3dll, PV_NONE, NULL, NULL,
{(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)NULL, (char_u *)0L}
#endif
SCTX_INIT},
{"pythonthreehome", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
#if defined(FEAT_PYTHON3)
(char_u *)&p_py3home, PV_NONE, NULL, NULL,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)NULL, (char_u *)0L}
#endif
SCTX_INIT},
{"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
#if defined(DYNAMIC_PYTHON)
(char_u *)&p_pydll, PV_NONE, NULL, NULL,
@@ -2031,6 +2013,24 @@ static struct vimoption options[] =
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)NULL, (char_u *)0L}
#endif
SCTX_INIT},
{"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
#if defined(DYNAMIC_PYTHON3)
(char_u *)&p_py3dll, PV_NONE, NULL, NULL,
{(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)NULL, (char_u *)0L}
#endif
SCTX_INIT},
{"pythonthreehome", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
#if defined(FEAT_PYTHON3)
(char_u *)&p_py3home, PV_NONE, NULL, NULL,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)NULL, (char_u *)0L}
#endif
SCTX_INIT},
{"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE,
@@ -2251,15 +2251,6 @@ static struct vimoption options[] =
(char_u *)NULL, PV_NONE, NULL, NULL,
#endif
{(char_u *)0L, (char_u *)0L} SCTX_INIT},
{"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
(char_u *)&p_sxq, PV_NONE, NULL, NULL,
{
#if defined(UNIX) && defined(USE_SYSTEM)
(char_u *)"\"",
#else
(char_u *)"",
#endif
(char_u *)0L} SCTX_INIT},
{"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
(char_u *)&p_sxe, PV_NONE, NULL, NULL,
{
@@ -2267,6 +2258,15 @@ static struct vimoption options[] =
(char_u *)"\"&|<>()@^",
#else
(char_u *)"",
#endif
(char_u *)0L} SCTX_INIT},
{"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
(char_u *)&p_sxq, PV_NONE, NULL, NULL,
{
#if defined(UNIX) && defined(USE_SYSTEM)
(char_u *)"\"",
#else
(char_u *)"",
#endif
(char_u *)0L} SCTX_INIT},
{"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
@@ -2850,16 +2850,16 @@ static struct vimoption options[] =
{"window", "wi", P_NUM|P_VI_DEF,
(char_u *)&p_window, PV_NONE, did_set_window, NULL,
{(char_u *)0L, (char_u *)0L} SCTX_INIT},
{"winheight", "wh", P_NUM|P_VI_DEF,
(char_u *)&p_wh, PV_NONE,
did_set_winheight_helpheight, NULL,
{(char_u *)1L, (char_u *)0L} SCTX_INIT},
{"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
(char_u *)VAR_WIN, PV_WFH, NULL, NULL,
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
(char_u *)VAR_WIN, PV_WFW, NULL, NULL,
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"winheight", "wh", P_NUM|P_VI_DEF,
(char_u *)&p_wh, PV_NONE,
did_set_winheight_helpheight, NULL,
{(char_u *)1L, (char_u *)0L} SCTX_INIT},
{"winminheight", "wmh", P_NUM|P_VI_DEF,
(char_u *)&p_wmh, PV_NONE, did_set_winminheight, NULL,
{(char_u *)1L, (char_u *)0L} SCTX_INIT},

View File

@@ -964,6 +964,9 @@ func Test_set_one_column()
let out_mult = execute('set all')->split("\n")
let out_one = execute('set! all')->split("\n")
call assert_true(len(out_mult) < len(out_one))
call assert_equal(out_one[0], '--- Options ---')
let options = out_one[1:]->mapnew({_, line -> line[2:]})
call assert_equal(sort(copy(options)), options)
endfunc
func Test_set_values()

View File

@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2154,
/**/
2153,
/**/