To: vim_dev@googlegroups.com Subject: Patch 9.0.1345 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1345 Problem: Too many "else if" statements for handling options. Solution: Add more functions to handle options. (Yegappan Lakshmanan, closes #12051) Files: src/optiondefs.h, src/optionstr.c, src/proto/optionstr.pro, src/testdir/test_options.vim *** ../vim-9.0.1344/src/optiondefs.h 2023-02-20 12:16:33.336269408 +0000 --- src/optiondefs.h 2023-02-23 15:02:36.857413581 +0000 *************** *** 479,485 **** (char_u *)NULL, PV_NONE, NULL, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, ! (char_u *)&p_bo, PV_NONE, NULL, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT, (char_u *)&p_bin, PV_BIN, did_set_binary, --- 479,485 ---- (char_u *)NULL, PV_NONE, NULL, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, ! (char_u *)&p_bo, PV_NONE, did_set_belloff, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT, (char_u *)&p_bin, PV_BIN, did_set_binary, *************** *** 530,536 **** #endif SCTX_INIT}, {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, ! (char_u *)&p_bh, PV_BH, NULL, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB, --- 530,536 ---- #endif SCTX_INIT}, {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, ! (char_u *)&p_bh, PV_BH, did_set_bufhidden, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB, *************** *** 542,548 **** {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, ! (char_u *)&p_cmp, PV_NONE, NULL, {(char_u *)"internal,keepascii", (char_u *)0L} SCTX_INIT}, {"cdhome", "cdh", P_BOOL|P_VI_DEF|P_VIM|P_SECURE, --- 542,548 ---- {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, ! (char_u *)&p_cmp, PV_NONE, did_set_casemap, {(char_u *)"internal,keepascii", (char_u *)0L} SCTX_INIT}, {"cdhome", "cdh", P_BOOL|P_VI_DEF|P_VIM|P_SECURE, *************** *** 606,612 **** {(char_u *)7L, (char_u *)0L} SCTX_INIT}, {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN, #ifdef FEAT_SYN_HL ! (char_u *)VAR_WIN, PV_CC, NULL, #else (char_u *)NULL, PV_NONE, NULL, #endif --- 606,612 ---- {(char_u *)7L, (char_u *)0L} SCTX_INIT}, {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN, #ifdef FEAT_SYN_HL ! (char_u *)VAR_WIN, PV_CC, did_set_colorcolumn, #else (char_u *)NULL, PV_NONE, NULL, #endif *************** *** 785,797 **** {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"cursorlineopt", "culopt", P_STRING|P_VI_DEF|P_RWIN|P_ONECOMMA|P_NODUP, #ifdef FEAT_SYN_HL ! (char_u *)VAR_WIN, PV_CULOPT, NULL, #else (char_u *)NULL, PV_NONE, NULL, #endif {(char_u *)"both", (char_u *)0L} SCTX_INIT}, {"debug", NULL, P_STRING|P_VI_DEF, ! (char_u *)&p_debug, PV_NONE, NULL, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT, #ifdef FEAT_FIND_ID --- 785,798 ---- {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"cursorlineopt", "culopt", P_STRING|P_VI_DEF|P_RWIN|P_ONECOMMA|P_NODUP, #ifdef FEAT_SYN_HL ! (char_u *)VAR_WIN, PV_CULOPT, ! did_set_cursorlineopt, #else (char_u *)NULL, PV_NONE, NULL, #endif {(char_u *)"both", (char_u *)0L} SCTX_INIT}, {"debug", NULL, P_STRING|P_VI_DEF, ! (char_u *)&p_debug, PV_NONE, did_set_debug, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT, #ifdef FEAT_FIND_ID *************** *** 850,856 **** (char_u *)&p_dy, PV_NONE, did_set_display, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"eadirection", "ead", P_STRING|P_VI_DEF, ! (char_u *)&p_ead, PV_NONE, NULL, {(char_u *)"both", (char_u *)0L} SCTX_INIT}, {"edcompatible","ed", P_BOOL|P_VI_DEF, --- 851,857 ---- (char_u *)&p_dy, PV_NONE, did_set_display, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"eadirection", "ead", P_STRING|P_VI_DEF, ! (char_u *)&p_ead, PV_NONE, did_set_eadirection, {(char_u *)"both", (char_u *)0L} SCTX_INIT}, {"edcompatible","ed", P_BOOL|P_VI_DEF, *************** *** 958,964 **** {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN, #ifdef FEAT_FOLDING ! (char_u *)&p_fcl, PV_NONE, NULL, {(char_u *)"", (char_u *)0L} #else (char_u *)NULL, PV_NONE, NULL, --- 959,965 ---- {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN, #ifdef FEAT_FOLDING ! (char_u *)&p_fcl, PV_NONE, did_set_foldclose, {(char_u *)"", (char_u *)0L} #else (char_u *)NULL, PV_NONE, NULL, *************** *** 1058,1064 **** SCTX_INIT}, {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT, #ifdef FEAT_FOLDING ! (char_u *)&p_fdo, PV_NONE, NULL, {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo", (char_u *)0L} #else --- 1059,1065 ---- SCTX_INIT}, {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT, #ifdef FEAT_FOLDING ! (char_u *)&p_fdo, PV_NONE, did_set_foldopen, {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo", (char_u *)0L} #else *************** *** 1772,1778 **** (char_u *)NULL, PV_NONE, NULL, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, ! (char_u *)&p_nf, PV_NF, NULL, {(char_u *)"bin,octal,hex", (char_u *)0L} SCTX_INIT}, {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN, --- 1773,1779 ---- (char_u *)NULL, PV_NONE, NULL, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, ! (char_u *)&p_nf, PV_NF, did_set_nrformats, {(char_u *)"bin,octal,hex", (char_u *)0L} SCTX_INIT}, {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN, *************** *** 2144,2150 **** (char_u *)&p_so, PV_SO, NULL, {(char_u *)0L, (char_u *)0L} SCTX_INIT}, {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, ! (char_u *)&p_sbo, PV_NONE, NULL, {(char_u *)"ver,jump", (char_u *)0L} SCTX_INIT}, {"sections", "sect", P_STRING|P_VI_DEF, --- 2145,2151 ---- (char_u *)&p_so, PV_SO, NULL, {(char_u *)0L, (char_u *)0L} SCTX_INIT}, {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, ! (char_u *)&p_sbo, PV_NONE, did_set_scrollopt, {(char_u *)"ver,jump", (char_u *)0L} SCTX_INIT}, {"sections", "sect", P_STRING|P_VI_DEF, *************** *** 2159,2165 **** {(char_u *)"inclusive", (char_u *)0L} SCTX_INIT}, {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, ! (char_u *)&p_slm, PV_NONE, NULL, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, #ifdef FEAT_SESSION --- 2160,2166 ---- {(char_u *)"inclusive", (char_u *)0L} SCTX_INIT}, {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, ! (char_u *)&p_slm, PV_NONE, did_set_selectmode, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, #ifdef FEAT_SESSION *************** *** 2281,2287 **** #endif } SCTX_INIT}, {"showcmdloc", "sloc", P_STRING|P_RSTAT, ! (char_u *)&p_sloc, PV_NONE, NULL, {(char_u *)"last", (char_u *)"last"} SCTX_INIT}, {"showfulltag", "sft", P_BOOL|P_VI_DEF, (char_u *)&p_sft, PV_NONE, NULL, --- 2282,2288 ---- #endif } SCTX_INIT}, {"showcmdloc", "sloc", P_STRING|P_RSTAT, ! (char_u *)&p_sloc, PV_NONE, did_set_showcmdloc, {(char_u *)"last", (char_u *)"last"} SCTX_INIT}, {"showfulltag", "sft", P_BOOL|P_VI_DEF, (char_u *)&p_sft, PV_NONE, NULL, *************** *** 2390,2396 **** (char_u *)&p_sb, PV_NONE, NULL, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"splitkeep", "spk", P_STRING, ! (char_u *)&p_spk, PV_NONE, NULL, {(char_u *)"cursor", (char_u *)"cursor"} SCTX_INIT}, {"splitright", "spr", P_BOOL|P_VI_DEF, (char_u *)&p_spr, PV_NONE, NULL, --- 2391,2397 ---- (char_u *)&p_sb, PV_NONE, NULL, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {"splitkeep", "spk", P_STRING, ! (char_u *)&p_spk, PV_NONE, did_set_splitkeep, {(char_u *)"cursor", (char_u *)"cursor"} SCTX_INIT}, {"splitright", "spr", P_BOOL|P_VI_DEF, (char_u *)&p_spr, PV_NONE, NULL, *************** *** 2420,2426 **** (char_u *)&p_sws, PV_NONE, NULL, {(char_u *)"fsync", (char_u *)0L} SCTX_INIT}, {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, ! (char_u *)&p_swb, PV_NONE, NULL, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF, #ifdef FEAT_SYN_HL --- 2421,2427 ---- (char_u *)&p_sws, PV_NONE, NULL, {(char_u *)"fsync", (char_u *)0L} SCTX_INIT}, {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, ! (char_u *)&p_swb, PV_NONE, did_set_switchbuf, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF, #ifdef FEAT_SYN_HL *************** *** 2553,2559 **** SCTX_INIT}, {"termwintype", "twt", P_STRING|P_ALLOCED|P_VI_DEF, #if defined(MSWIN) && defined(FEAT_TERMINAL) ! (char_u *)&p_twt, PV_NONE, NULL, {(char_u *)"", (char_u *)NULL} #else (char_u *)NULL, PV_NONE, NULL, --- 2554,2560 ---- SCTX_INIT}, {"termwintype", "twt", P_STRING|P_ALLOCED|P_VI_DEF, #if defined(MSWIN) && defined(FEAT_TERMINAL) ! (char_u *)&p_twt, PV_NONE, did_set_termwintype, {(char_u *)"", (char_u *)NULL} #else (char_u *)NULL, PV_NONE, NULL, *************** *** 2731,2737 **** SCTX_INIT}, {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, #ifdef FEAT_SESSION ! (char_u *)&p_vop, PV_NONE, NULL, {(char_u *)"folds,options,cursor,curdir", (char_u *)0L} #else --- 2732,2738 ---- SCTX_INIT}, {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, #ifdef FEAT_SESSION ! (char_u *)&p_vop, PV_NONE, did_set_viewoptions, {(char_u *)"folds,options,cursor,curdir", (char_u *)0L} #else *************** *** 2811,2817 **** (char_u *)&p_wim, PV_NONE, did_set_wildmode, {(char_u *)"full", (char_u *)0L} SCTX_INIT}, {"wildoptions", "wop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, ! (char_u *)&p_wop, PV_NONE, NULL, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"winaltkeys", "wak", P_STRING|P_VI_DEF, --- 2812,2818 ---- (char_u *)&p_wim, PV_NONE, did_set_wildmode, {(char_u *)"full", (char_u *)0L} SCTX_INIT}, {"wildoptions", "wop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, ! (char_u *)&p_wop, PV_NONE, did_set_wildoptions, {(char_u *)"", (char_u *)0L} SCTX_INIT}, {"winaltkeys", "wak", P_STRING|P_VI_DEF, *************** *** 2824,2830 **** #endif SCTX_INIT}, {"wincolor", "wcr", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN, ! (char_u *)VAR_WIN, PV_WCR, NULL, {(char_u *)"", (char_u *)NULL} SCTX_INIT}, {"window", "wi", P_NUM|P_VI_DEF, --- 2825,2831 ---- #endif SCTX_INIT}, {"wincolor", "wcr", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN, ! (char_u *)VAR_WIN, PV_WCR, did_set_wincolor, {(char_u *)"", (char_u *)NULL} SCTX_INIT}, {"window", "wi", P_NUM|P_VI_DEF, *** ../vim-9.0.1344/src/optionstr.c 2023-02-21 14:27:34.520360383 +0000 --- src/optionstr.c 2023-02-23 15:02:36.857413581 +0000 *************** *** 792,803 **** #ifdef FEAT_SYN_HL /* * The 'cursorlineopt' option is changed. */ ! static char * ! did_set_cursorlineopt(char_u **varp) { ! if (**varp == NUL || fill_culopt_flags(*varp, curwin) != OK) return e_invalid_argument; return NULL; --- 792,813 ---- #ifdef FEAT_SYN_HL /* + * The 'colorcolumn' option is changed. + */ + char * + did_set_colorcolumn(optset_T *args UNUSED) + { + return check_colorcolumn(curwin); + } + + /* * The 'cursorlineopt' option is changed. */ ! char * ! did_set_cursorlineopt(optset_T *args) { ! if (*args->os_varp == NUL ! || fill_culopt_flags(args->os_varp, curwin) != OK) return e_invalid_argument; return NULL; *************** *** 864,870 **** return did_set_opt_flags(val, values, NULL, list); } ! #ifdef FEAT_SESSION /* * The 'sessionoptions' option is changed. */ --- 874,943 ---- return did_set_opt_flags(val, values, NULL, list); } ! /* ! * The 'belloff' option is changed. ! */ ! char * ! did_set_belloff(optset_T *args UNUSED) ! { ! return did_set_opt_flags(p_bo, p_bo_values, &bo_flags, TRUE); ! } ! ! /* ! * The 'casemap' option is changed. ! */ ! char * ! did_set_casemap(optset_T *args UNUSED) ! { ! return did_set_opt_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE); ! } ! ! /* ! * The 'scrollopt' option is changed. ! */ ! char * ! did_set_scrollopt(optset_T *args UNUSED) ! { ! return did_set_opt_strings(p_sbo, p_scbopt_values, TRUE); ! } ! ! /* ! * The 'selectmode' option is changed. ! */ ! char * ! did_set_selectmode(optset_T *args UNUSED) ! { ! return did_set_opt_strings(p_slm, p_slm_values, TRUE); ! } ! ! /* ! * The 'showcmdloc' option is changed. ! */ ! char * ! did_set_showcmdloc(optset_T *args UNUSED) ! { ! return did_set_opt_strings(p_sloc, p_sloc_values, FALSE); ! } ! ! /* ! * The 'splitkeep' option is changed. ! */ ! char * ! did_set_splitkeep(optset_T *args UNUSED) ! { ! return did_set_opt_strings(p_spk, p_spk_values, FALSE); ! } ! ! /* ! * The 'switchbuf' option is changed. ! */ ! char * ! did_set_switchbuf(optset_T *args UNUSED) ! { ! return did_set_opt_flags(p_swb, p_swb_values, &swb_flags, TRUE); ! } ! ! #if defined(FEAT_SESSION) || defined(PROTO) /* * The 'sessionoptions' option is changed. */ *************** *** 883,888 **** --- 956,970 ---- return NULL; } + + /* + * The 'viewoptions' option is changed. + */ + char * + did_set_viewoptions(optset_T *args UNUSED) + { + return did_set_opt_flags(p_vop, p_ssop_values, &vop_flags, TRUE); + } #endif /* *************** *** 944,949 **** --- 1026,1040 ---- return NULL; } + /* + * The 'wildoptions' option is changed. + */ + char * + did_set_wildoptions(optset_T *args UNUSED) + { + return did_set_opt_strings(p_wop, p_wop_values, TRUE); + } + #if defined(FEAT_WAK) || defined(PROTO) /* * The 'winaltkeys' option is changed. *************** *** 970,975 **** --- 1061,1087 ---- #endif /* + * The 'wincolor' option is changed. + */ + char * + did_set_wincolor(optset_T *args UNUSED) + { + #ifdef FEAT_TERMINAL + term_update_wincolor(curwin); + #endif + return NULL; + } + + /* + * The 'eadirection' option is changed. + */ + char * + did_set_eadirection(optset_T *args UNUSED) + { + return did_set_opt_strings(p_ead, p_ead_values, FALSE); + } + + /* * The 'eventignore' option is changed. */ char * *************** *** 1857,1862 **** --- 1969,1983 ---- } /* + * The 'debug' option is changed. + */ + char * + did_set_debug(optset_T *args UNUSED) + { + return did_set_opt_strings(p_debug, p_debug_values, TRUE); + } + + /* * The 'display' option is changed. */ char * *************** *** 1946,1951 **** --- 2067,2081 ---- #endif /* + * The 'nrformats' option is changed. + */ + char * + did_set_nrformats(optset_T *args) + { + return did_set_opt_strings(args->os_varp, p_nf_values, TRUE); + } + + /* * The 'buftype' option is changed. */ char * *************** *** 2198,2203 **** --- 2328,2342 ---- } /* + * The 'bufhidden' option is changed. + */ + char * + did_set_bufhidden(optset_T *args UNUSED) + { + return did_set_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE); + } + + /* * The 'tagcase' option is changed. */ char * *************** *** 2299,2304 **** --- 2438,2461 ---- foldUpdateAll(curwin); return NULL; } + + /* + * The 'foldclose' option is changed. + */ + char * + did_set_foldclose(optset_T *args UNUSED) + { + return did_set_opt_strings(p_fcl, p_fcl_values, TRUE); + } + + /* + * The 'foldopen' option is changed. + */ + char * + did_set_foldopen(optset_T *args UNUSED) + { + return did_set_opt_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE); + } #endif /* *************** *** 2459,2464 **** --- 2616,2632 ---- return NULL; } + + # if defined(MSWIN) || defined(PROTO) + /* + * The 'termwintype' option is changed. + */ + char * + did_set_termwintype(optset_T *args UNUSED) + { + return did_set_opt_strings(p_twt, p_twt_values, FALSE); + } + # endif #endif #if defined(FEAT_VARTABS) || defined(PROTO) *************** *** 2753,2775 **** || varp == &p_isp // 'isprint' || varp == &p_isf) // 'isfname' errmsg = did_set_isopt(&did_chartab); - #ifdef FEAT_SYN_HL - else if ( varp == &curwin->w_p_culopt // 'cursorlineopt' - || gvarp == &curwin->w_allbuf_opt.wo_culopt) - errmsg = did_set_cursorlineopt(varp); - else if (varp == &curwin->w_p_cc) // 'colorcolumn' - errmsg = check_colorcolumn(curwin); - #endif - else if (gvarp == &p_nf) // 'nrformats' - errmsg = did_set_opt_strings(*varp, p_nf_values, TRUE); - #ifdef FEAT_SESSION - else if (varp == &p_vop) // 'viewoptions' - errmsg = did_set_opt_flags(p_vop, p_ssop_values, &vop_flags, TRUE); - #endif - else if (varp == &p_sbo) // 'scrollopt' - errmsg = did_set_opt_strings(p_sbo, p_scbopt_values, TRUE); - else if (varp == &p_wop) // 'wildoptions' - errmsg = did_set_opt_strings(p_wop, p_wop_values, TRUE); else if ( varp == &p_enc // 'encoding' || gvarp == &p_fenc // 'fileencoding' || varp == &p_tenc // 'termencoding' --- 2921,2926 ---- *************** *** 2799,2831 **** else if (varp == &p_guicursor) // 'guicursor' errmsg = parse_shape_opt(SHAPE_CURSOR); #endif - else if (varp == &p_slm) // 'selectmode' - errmsg = did_set_opt_strings(p_slm, p_slm_values, TRUE); - else if (varp == &p_swb) // 'switchbuf' - errmsg = did_set_opt_flags(p_swb, p_swb_values, &swb_flags, TRUE); - else if (varp == &p_spk) // 'splitkeep' - errmsg = did_set_opt_strings(p_spk, p_spk_values, FALSE); - else if (varp == &p_debug) // 'debug' - errmsg = did_set_opt_strings(p_debug, p_debug_values, TRUE); - else if (varp == &p_ead) // 'eadirection' - errmsg = did_set_opt_strings(p_ead, p_ead_values, FALSE); - else if (gvarp == &p_bh) // 'bufhidden' - errmsg = did_set_opt_strings(curbuf->b_p_bh, p_bufhidden_values, - FALSE); else if (gvarp == &p_cpt) // 'complete' errmsg = did_set_complete(varp, errbuf); - else if (varp == &p_sloc) // 'showcmdloc' - errmsg = did_set_opt_strings(p_sloc, p_sloc_values, FALSE); - else if (varp == &p_bo) // 'belloff' - errmsg = did_set_opt_flags(p_bo, p_bo_values, &bo_flags, TRUE); - else if (varp == &p_cmp) // 'casemap' - errmsg = did_set_opt_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE); - #ifdef FEAT_FOLDING - else if (varp == &p_fdo) // 'foldopen' - errmsg = did_set_opt_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE); - else if (varp == &p_fcl) // 'foldclose' - errmsg = did_set_opt_strings(p_fcl, p_fcl_values, TRUE); - #endif else if (gvarp == &p_ft) // 'filetype' errmsg = did_set_filetype_or_syntax(varp, oldval, value_checked, &value_changed); --- 2950,2957 ---- *************** *** 2834,2847 **** errmsg = did_set_filetype_or_syntax(varp, oldval, value_checked, &value_changed); #endif - #ifdef FEAT_TERMINAL - else if (varp == &curwin->w_p_wcr) // 'wincolor' - term_update_wincolor(curwin); - # if defined(MSWIN) - else if (varp == &p_twt) // 'termwintype' - errmsg = did_set_opt_strings(p_twt, p_twt_values, FALSE); - # endif - #endif #ifdef FEAT_EVAL else if ( # ifdef FEAT_BEVAL --- 2960,2965 ---- *** ../vim-9.0.1344/src/proto/optionstr.pro 2023-02-20 12:16:33.336269408 +0000 --- src/proto/optionstr.pro 2023-02-23 15:03:24.373491321 +0000 *************** *** 13,25 **** --- 13,38 ---- char *did_set_backupext_or_patchmode(optset_T *args); char *did_set_breakindentopt(optset_T *args); char *did_set_helpfile(optset_T *args); + char *did_set_colorcolumn(optset_T *args); + char *did_set_cursorlineopt(optset_T *args); char *did_set_helplang(optset_T *args); char *did_set_highlight(optset_T *args); + char *did_set_belloff(optset_T *args); + char *did_set_casemap(optset_T *args); + char *did_set_scrollopt(optset_T *args); + char *did_set_selectmode(optset_T *args); + char *did_set_showcmdloc(optset_T *args); + char *did_set_splitkeep(optset_T *args); + char *did_set_switchbuf(optset_T *args); char *did_set_sessionoptions(optset_T *args); + char *did_set_viewoptions(optset_T *args); char *did_set_ambiwidth(optset_T *args); char *did_set_background(optset_T *args); char *did_set_wildmode(optset_T *args); + char *did_set_wildoptions(optset_T *args); char *did_set_winaltkeys(optset_T *args); + char *did_set_wincolor(optset_T *args); + char *did_set_eadirection(optset_T *args); char *did_set_eventignore(optset_T *args); char *did_set_printencoding(optset_T *args); char *did_set_imactivatekey(optset_T *args); *************** *** 45,50 **** --- 58,64 ---- char *did_set_keymodel(optset_T *args); char *did_set_keyprotocol(optset_T *args); char *did_set_mousemodel(optset_T *args); + char *did_set_debug(optset_T *args); char *did_set_display(optset_T *args); char *did_set_spellfile(optset_T *args); char *did_set_spelllang(optset_T *args); *************** *** 52,57 **** --- 66,72 ---- char *did_set_spelloptions(optset_T *args); char *did_set_spellsuggest(optset_T *args); char *did_set_mkspellmem(optset_T *args); + char *did_set_nrformats(optset_T *args); char *did_set_buftype(optset_T *args); char *did_set_statusline(optset_T *args); char *did_set_tabline(optset_T *args); *************** *** 63,74 **** --- 78,92 ---- char *did_set_toolbariconsize(optset_T *args); char *did_set_pastetoggle(optset_T *args); char *did_set_backspace(optset_T *args); + char *did_set_bufhidden(optset_T *args); char *did_set_tagcase(optset_T *args); char *did_set_diffopt(optset_T *args); char *did_set_foldmethod(optset_T *args); char *did_set_foldmarker(optset_T *args); char *did_set_commentstring(optset_T *args); char *did_set_foldignore(optset_T *args); + char *did_set_foldclose(optset_T *args); + char *did_set_foldopen(optset_T *args); char *did_set_virtualedit(optset_T *args); char *did_set_cscopequickfix(optset_T *args); char *did_set_cinoptions(optset_T *args); *************** *** 76,81 **** --- 94,100 ---- char *did_set_renderoptions(optset_T *args); char *did_set_termwinkey(optset_T *args); char *did_set_termwinsize(optset_T *args); + char *did_set_termwintype(optset_T *args); char *did_set_varsofttabstop(optset_T *args); char *did_set_vartabstop(optset_T *args); char *did_set_previewpopup(optset_T *args); *** ../vim-9.0.1344/src/testdir/test_options.vim 2023-02-13 16:10:00.375551633 +0000 --- src/testdir/test_options.vim 2023-02-23 15:02:36.857413581 +0000 *************** *** 437,443 **** if has('mouseshape') call assert_fails('se mouseshape=i-r:x', 'E547:') endif ! call assert_fails('set backupext=~ patchmode=~', 'E589:') call assert_fails('set winminheight=10 winheight=9', 'E591:') set winminheight& winheight& set winheight=10 winminheight=10 --- 437,452 ---- if has('mouseshape') call assert_fails('se mouseshape=i-r:x', 'E547:') endif ! ! " Test for 'backupext' and 'patchmode' set to the same value ! set backupext=.bak ! set patchmode=.patch ! call assert_fails('set patchmode=.bak', 'E589:') ! call assert_equal('.patch', &patchmode) ! call assert_fails('set backupext=.patch', 'E589:') ! call assert_equal('.bak', &backupext) ! set backupext& patchmode& ! call assert_fails('set winminheight=10 winheight=9', 'E591:') set winminheight& winheight& set winheight=10 winminheight=10 *************** *** 1506,1509 **** --- 1515,1586 ---- let &columns = save_columns endfunc + " Test for reverting a string option value if the new value is invalid. + func Test_string_option_revert_on_failure() + new + let optlist = [ + \ ['ambiwidth', 'double', 'a123'], + \ ['background', 'dark', 'a123'], + \ ['backspace', 'eol', 'a123'], + \ ['backupcopy', 'no', 'a123'], + \ ['belloff', 'showmatch', 'a123'], + \ ['breakindentopt', 'min:10', 'list'], + \ ['bufhidden', 'wipe', 'a123'], + \ ['buftype', 'nowrite', 'a123'], + \ ['casemap', 'keepascii', 'a123'], + \ ['cedit', "\", 'z'], + \ ['colorcolumn', '10', 'z'], + \ ['commentstring', '#%s', 'a123'], + \ ['complete', '.,t', 'a'], + \ ['completefunc', 'MyCmplFunc', '1a-'], + \ ['completeopt', 'popup', 'a123'], + \ ['completepopup', 'width:20', 'border'], + \ ['concealcursor', 'v', 'xyz'], + \ ['cpoptions', 'HJ', '~'], + \ ['cryptmethod', 'zip', 'a123'], + \ ['cursorlineopt', 'screenline', 'a123'], + \ ['debug', 'throw', 'a123'], + \ ['diffopt', 'iwhite', 'a123'], + \ ['display', 'uhex', 'a123'], + \ ['eadirection', 'hor', 'a123'], + \ ['encoding', 'utf-8', 'a123'], + \ ['eventignore', 'TextYankPost', 'a123'], + \ ['fileencoding', 'utf-8', 'a123,'], + \ ['fileformat', 'mac', 'a123'], + \ ['fileformats', 'mac', 'a123'], + \ ['fillchars', 'diff:~', 'a123'], + \ ['foldclose', 'all', 'a123'], + \ ['foldmarker', '[[[,]]]', '[[['], + \ ['foldmethod', 'marker', 'a123'], + \ ['foldopen', 'percent', 'a123'], + \ ['formatoptions', 'an', '*'], + \ ['guicursor', 'n-v-c:block-Cursor/lCursor', 'n-v-c'], + \ ['helplang', 'en', 'a'], + \ ['highlight', '!:CursorColumn', '8:'] + \ ] + if has('gui') + call add(optlist, ['browsedir', 'buffer', 'a123']) + endif + if has('clipboard_working') + call add(optlist, ['clipboard', 'unnamed', 'a123']) + endif + if has('win32') + call add(optlist, ['completeslash', 'slash', 'a123']) + endif + if has('cscope') + call add(optlist, ['cscopequickfix', 't-', 'z-']) + endif + if !has('win32') + call add(optlist, ['imactivatefunc', 'MyCmplFunc', '1a-']) + endif + for opt in optlist + exe $"let save_opt = &{opt[0]}" + exe $"let &{opt[0]} = '{opt[1]}'" + call assert_fails($"let &{opt[0]} = '{opt[2]}'", '', opt[0]) + call assert_equal(opt[1], eval($"&{opt[0]}"), opt[0]) + exe $"let &{opt[0]} = save_opt" + endfor + bw! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.1344/src/version.c 2023-02-23 13:53:58.247215042 +0000 --- src/version.c 2023-02-23 15:03:16.945479200 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1345, /**/ -- Very funny, Scotty. Now beam down my clothes. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///