diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-12-08 21:34:31 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2023-12-08 21:36:55 +0100 |
commit | f48558e10a08a1a483e25ef847bbceeac6b44561 (patch) | |
tree | 5f5d68ff220a64256c3167fbaccbdb5006881404 /src | |
parent | ff0baca86523f1e8c6ea593ec0ef2f9860f001d0 (diff) |
patch 9.0.2154: The option[] array is not sortedv9.0.2154
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/option.c | 4 | ||||
-rw-r--r-- | src/optiondefs.h | 156 | ||||
-rw-r--r-- | src/testdir/test_options.vim | 3 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 86 insertions, 79 deletions
diff --git a/src/option.c b/src/option.c index df81cf33bd..4d12834f2e 100644 --- a/src/option.c +++ b/src/option.c @@ -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])]; diff --git a/src/optiondefs.h b/src/optiondefs.h index 10f2aff131..658e17d16d 100644 --- a/src/optiondefs.h +++ b/src/optiondefs.h @@ -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,18 +355,23 @@ static struct vimoption options[] = (char_u *)&p_ambw, PV_NONE, did_set_ambiwidth, expand_set_ambiwidth, {(char_u *)"single", (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, - {(char_u *)FALSE, (char_u *)0L} + {"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, - {(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} 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, {(char_u *)FALSE, (char_u *)0L} #else (char_u *)NULL, PV_NONE, NULL, NULL, @@ -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,36 +1997,36 @@ 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} + {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, +#if defined(DYNAMIC_PYTHON) + (char_u *)&p_pydll, PV_NONE, NULL, NULL, + {(char_u *)DYNAMIC_PYTHON_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, + {"pythonhome", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, +#if defined(FEAT_PYTHON) + (char_u *)&p_pyhome, 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, - {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L} + {"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}, - {"pythonhome", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, -#if defined(FEAT_PYTHON) - (char_u *)&p_pyhome, PV_NONE, NULL, NULL, + {"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, @@ -2251,20 +2251,20 @@ 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, + {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE, + (char_u *)&p_sxe, PV_NONE, NULL, NULL, { -#if defined(UNIX) && defined(USE_SYSTEM) - (char_u *)"\"", +#if defined(MSWIN) + (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, + {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE, + (char_u *)&p_sxq, PV_NONE, NULL, NULL, { -#if defined(MSWIN) - (char_u *)"\"&|<>()@^", +#if defined(UNIX) && defined(USE_SYSTEM) + (char_u *)"\"", #else (char_u *)"", #endif @@ -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}, diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim index f65654dc5c..8c336abf7d 100644 --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -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() diff --git a/src/version.c b/src/version.c index dc39b5ca21..f623c7f6fc 100644 --- a/src/version.c +++ b/src/version.c @@ -705,6 +705,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2154, +/**/ 2153, /**/ 2152, |