diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2023-04-28 23:40:34 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-28 23:40:34 +0800 |
| commit | 233b858f2a2f3b57d07675e2de45736da36709e8 (patch) | |
| tree | a8aef6d891e43fb68672d17d924b9d9bf3f6b88b /src | |
| parent | ca7e488cfeb16b3eb2faf9613718f17d28f0f005 (diff) | |
| parent | 2722bff0f35bb4b69a297f8b4fae17661bbfe26f (diff) | |
| download | rneovim-233b858f2a2f3b57d07675e2de45736da36709e8.tar.gz rneovim-233b858f2a2f3b57d07675e2de45736da36709e8.tar.bz2 rneovim-233b858f2a2f3b57d07675e2de45736da36709e8.zip | |
Merge pull request #23162 from lewis6991/vimpatch/option_cb
vim-patch:9.0.{1330,1345,1353,1359,1369,1374}: handling new value of an option has a long "else if" chain
Diffstat (limited to 'src')
| -rw-r--r-- | src/nvim/buffer.c | 2 | ||||
| -rw-r--r-- | src/nvim/eval/funcs.c | 4 | ||||
| -rw-r--r-- | src/nvim/ex_cmds.c | 2 | ||||
| -rw-r--r-- | src/nvim/ex_getln.c | 2 | ||||
| -rw-r--r-- | src/nvim/generators/gen_options.lua | 3 | ||||
| -rw-r--r-- | src/nvim/insexpand.c | 19 | ||||
| -rw-r--r-- | src/nvim/lua/spell.c | 2 | ||||
| -rw-r--r-- | src/nvim/mapping.c | 17 | ||||
| -rw-r--r-- | src/nvim/ops.c | 5 | ||||
| -rw-r--r-- | src/nvim/option.c | 515 | ||||
| -rw-r--r-- | src/nvim/option_defs.h | 59 | ||||
| -rw-r--r-- | src/nvim/options.lua | 512 | ||||
| -rw-r--r-- | src/nvim/optionstr.c | 1269 | ||||
| -rw-r--r-- | src/nvim/quickfix.c | 5 | ||||
| -rw-r--r-- | src/nvim/runtime.c | 3 | ||||
| -rw-r--r-- | src/nvim/spell.c | 6 | ||||
| -rw-r--r-- | src/nvim/spellfile.c | 2 | ||||
| -rw-r--r-- | src/nvim/spellsuggest.c | 2 | ||||
| -rw-r--r-- | src/nvim/tag.c | 17 | ||||
| -rw-r--r-- | src/nvim/window.c | 6 |
20 files changed, 1505 insertions, 947 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index c63ab804af..14a07489a0 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1687,7 +1687,7 @@ void enter_buffer(buf_T *buf) // May need to set the spell language. Can only do this after the buffer // has been properly setup. if (!curbuf->b_help && curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) { - (void)did_set_spelllang(curwin); + (void)parse_spelllang(curwin); } curbuf->b_last_used = time(NULL); diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index ebc34564e2..f898063fb0 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -7711,7 +7711,7 @@ static void f_spellbadword(typval_T *argvars, typval_T *rettv, EvalFuncData fptr const int wo_spell_save = curwin->w_p_spell; if (!curwin->w_p_spell) { - did_set_spelllang(curwin); + parse_spelllang(curwin); curwin->w_p_spell = true; } @@ -7768,7 +7768,7 @@ static void f_spellsuggest(typval_T *argvars, typval_T *rettv, EvalFuncData fptr const int wo_spell_save = curwin->w_p_spell; if (!curwin->w_p_spell) { - did_set_spelllang(curwin); + parse_spelllang(curwin); curwin->w_p_spell = true; } diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 7a77ffb4da..f276e8ae24 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2640,7 +2640,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum // If the window options were changed may need to set the spell language. // Can only do this after the buffer has been properly setup. if (did_get_winopts && curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) { - (void)did_set_spelllang(curwin); + (void)parse_spelllang(curwin); } if (command == NULL) { diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 33a8dcafc2..c0c8a5605b 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4277,7 +4277,7 @@ void cmdline_init(void) /// Check value of 'cedit' and set cedit_key. /// Returns NULL if value is OK, error message otherwise. -const char *check_cedit(void) +const char *did_set_cedit(optset_T *args) { if (*p_cedit == NUL) { cedit_key = -1; diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index 35302e1222..ecb1a0c11b 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -154,6 +154,9 @@ local dump_option = function(i, o) table.insert(defines, { 'PV_' .. varname:sub(3):upper() , pv_name}) w(' .indir=' .. pv_name) end + if o.cb then + w(' .opt_did_set_cb=' .. o.cb) + end if o.enable_if then w('#else') w(' .var=NULL') diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 6624b39d0c..d6860fff30 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -2257,14 +2257,14 @@ static void copy_global_to_buflocal_cb(Callback *globcb, Callback *bufcb) /// Invoked when the 'completefunc' option is set. The option value can be a /// name of a function (string), or function(<name>) or funcref(<name>) or a /// lambda expression. -void set_completefunc_option(const char **errmsg) +const char *did_set_completefunc(optset_T *args FUNC_ATTR_UNUSED) { if (option_set_callback_func(curbuf->b_p_cfu, &cfu_cb) == FAIL) { - *errmsg = e_invarg; - return; + return e_invarg; } set_buflocal_cfu_callback(curbuf); + return NULL; } /// Copy the global 'completefunc' callback function to the buffer-local @@ -2278,13 +2278,14 @@ void set_buflocal_cfu_callback(buf_T *buf) /// Invoked when the 'omnifunc' option is set. The option value can be a /// name of a function (string), or function(<name>) or funcref(<name>) or a /// lambda expression. -void set_omnifunc_option(buf_T *buf, const char **errmsg) +const char *did_set_omnifunc(optset_T *args) { + buf_T *buf = (buf_T *)args->os_buf; if (option_set_callback_func(buf->b_p_ofu, &ofu_cb) == FAIL) { - *errmsg = e_invarg; - return; + return e_invarg; } set_buflocal_ofu_callback(buf); + return NULL; } /// Copy the global 'omnifunc' callback function to the buffer-local 'omnifunc' @@ -2298,7 +2299,7 @@ void set_buflocal_ofu_callback(buf_T *buf) /// Invoked when the 'thesaurusfunc' option is set. The option value can be a /// name of a function (string), or function(<name>) or funcref(<name>) or a /// lambda expression. -void set_thesaurusfunc_option(const char **errmsg) +const char *did_set_thesaurusfunc(optset_T *args FUNC_ATTR_UNUSED) { int retval; @@ -2310,9 +2311,7 @@ void set_thesaurusfunc_option(const char **errmsg) retval = option_set_callback_func(p_tsrfu, &tsrfu_cb); } - if (retval == FAIL) { - *errmsg = e_invarg; - } + return retval == FAIL ? e_invarg : NULL; } /// Mark the global 'completefunc' 'omnifunc' and 'thesaurusfunc' callbacks with diff --git a/src/nvim/lua/spell.c b/src/nvim/lua/spell.c index 742e8720f9..37f1c5216d 100644 --- a/src/nvim/lua/spell.c +++ b/src/nvim/lua/spell.c @@ -39,7 +39,7 @@ int nlua_spell_check(lua_State *lstate) const int wo_spell_save = curwin->w_p_spell; if (!curwin->w_p_spell) { - did_set_spelllang(curwin); + parse_spelllang(curwin); curwin->w_p_spell = true; } diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 9a835e0eb8..c1d02e89b8 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -2386,7 +2386,7 @@ void langmap_init(void) /// Called when langmap option is set; the language map can be /// changed at any time! -void langmap_set(void) +const char *did_set_langmap(optset_T *args) { char *p; char *p2; @@ -2434,9 +2434,10 @@ void langmap_set(void) } } if (to == NUL) { - semsg(_("E357: 'langmap': Matching character missing for %s"), - transchar(from)); - return; + snprintf(args->os_errbuf, args->os_errbuflen, + _("E357: 'langmap': Matching character missing for %s"), + transchar(from)); + return args->os_errbuf; } if (from >= 256) { @@ -2454,8 +2455,10 @@ void langmap_set(void) p = p2; if (p[0] != NUL) { if (p[0] != ',') { - semsg(_("E358: 'langmap': Extra characters after semicolon: %s"), p); - return; + snprintf(args->os_errbuf, args->os_errbuflen, + _("E358: 'langmap': Extra characters after semicolon: %s"), + p); + return args->os_errbuf; } p++; } @@ -2464,6 +2467,8 @@ void langmap_set(void) } } } + + return NULL; } static void do_exmap(exarg_T *eap, int isabbrev) diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 2919b94d41..89fe9b464d 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -5628,11 +5628,12 @@ static void op_colon(oparg_T *oap) static Callback opfunc_cb; /// Process the 'operatorfunc' option value. -void set_operatorfunc_option(const char **errmsg) +const char *did_set_operatorfunc(optset_T *args FUNC_ATTR_UNUSED) { if (option_set_callback_func(p_opfunc, &opfunc_cb) == FAIL) { - *errmsg = e_invarg; + return e_invarg; } + return NULL; } #if defined(EXITFREE) diff --git a/src/nvim/option.c b/src/nvim/option.c index 040ab1b847..3264d80a2f 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -84,6 +84,7 @@ #include "nvim/path.h" #include "nvim/popupmenu.h" #include "nvim/pos.h" +#include "nvim/quickfix.h" #include "nvim/regexp.h" #include "nvim/runtime.h" #include "nvim/search.h" @@ -135,17 +136,6 @@ static long p_tw_nopaste; static long p_wm_nopaste; static char *p_vsts_nopaste; -// options[] is initialized here. -// The order of the options MUST be alphabetic for ":set all" and findoption(). -// All option names MUST start with a lowercase letter (for findoption()). -// Exception: "t_" options are at the end. -// The options with a NULL variable are 'hidden': a set command for them is -// ignored and they are not printed. - -#ifdef INCLUDE_GENERATED_DECLARATIONS -# include "options.generated.h" -#endif - #define OPTION_COUNT ARRAY_SIZE(options) typedef enum { @@ -159,6 +149,17 @@ typedef enum { # include "option.c.generated.h" #endif +// options[] is initialized here. +// The order of the options MUST be alphabetic for ":set all" and findoption(). +// All option names MUST start with a lowercase letter (for findoption()). +// Exception: "t_" options are at the end. +// The options with a NULL variable are 'hidden': a set command for them is +// ignored and they are not printed. + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "options.generated.h" +#endif + void set_init_tablocal(void) { // susy baka: cmdheight calls itself OPT_GLOBAL but is really tablocal! @@ -1237,7 +1238,7 @@ static void do_set_option_string(int opt_idx, int opt_flags, char **argp, int ne // Handle side effects, and set the global value for ":set" on local // options. Note: when setting 'syntax' or 'filetype' autocommands may // be triggered that can cause havoc. - *errmsg = did_set_string_option(opt_idx, (char **)varp, oldval, + *errmsg = did_set_string_option(opt_idx, (char **)varp, oldval, newval, errbuf, errbuflen, opt_flags, value_checked); @@ -1840,9 +1841,9 @@ static void didset_options(void) (void)compile_cap_prog(curwin->w_s); (void)did_set_spell_option(true); // set cedit_key - (void)check_cedit(); + (void)did_set_cedit(NULL); // initialize the table for 'breakat'. - fill_breakat_flags(); + (void)did_set_breakat(NULL); didset_window_options(curwin, true); } @@ -1853,10 +1854,10 @@ static void didset_options2(void) highlight_changed(); // Parse default for 'fillchars'. - (void)set_chars_option(curwin, &curwin->w_p_fcs, true); + (void)set_fillchars_option(curwin, curwin->w_p_fcs, true); // Parse default for 'listchars'. - (void)set_chars_option(curwin, &curwin->w_p_lcs, true); + (void)set_listchars_option(curwin, curwin->w_p_lcs, true); // Parse default for 'wildmode'. check_opt_wim(); @@ -2101,25 +2102,27 @@ static const char *did_set_force_off(bool *doskip) } /// Process the updated 'langremap' option value. -static void did_set_langremap(void) +static const char *did_set_langremap(optset_T *args FUNC_ATTR_UNUSED) { // 'langremap' -> !'langnoremap' p_lnr = !p_lrm; + return NULL; } /// Process the updated 'langnoremap' option value. -static void did_set_langnoremap(void) +static const char *did_set_langnoremap(optset_T *args FUNC_ATTR_UNUSED) { // 'langnoremap' -> !'langremap' p_lrm = !p_lnr; + return NULL; } /// Process the updated 'undofile' option value. -static void did_set_undofile(int opt_flags) +static const char *did_set_undofile(optset_T *args) { // Only take action when the option was set. if (!curbuf->b_p_udf && !p_udf) { - return; + return NULL; } // When reset we do not delete the undo file, the option may be set again @@ -2132,19 +2135,21 @@ static void did_set_undofile(int opt_flags) // if one exists, the buffer wasn't changed and the buffer was // loaded if ((curbuf == bp - || (opt_flags & OPT_GLOBAL) || opt_flags == 0) + || (args->os_flags & OPT_GLOBAL) || args->os_flags == 0) && !bufIsChanged(bp) && bp->b_ml.ml_mfp != NULL) { u_compute_hash(bp, hash); u_read_undo(NULL, hash, bp->b_fname); } } + + return NULL; } /// Process the updated 'readonly' option value. -static void did_set_readonly(int opt_flags) +static const char *did_set_readonly(optset_T *args) { // when 'readonly' is reset globally, also reset readonlymode - if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) { + if (!curbuf->b_p_ro && (args->os_flags & OPT_LOCAL) == 0) { readonlymode = false; } @@ -2154,10 +2159,12 @@ static void did_set_readonly(int opt_flags) } redraw_titles(); + + return NULL; } /// Process the updated 'modifiable' option value. -static char *did_set_modifiable(void) +static const char *did_set_modifiable(optset_T *args FUNC_ATTR_UNUSED) { // when 'modifiable' is changed, redraw the window title redraw_titles(); @@ -2167,90 +2174,108 @@ static char *did_set_modifiable(void) /// Process the updated 'endoffile' or 'endofline' or 'fixendofline' or 'bomb' /// option value. -static void did_set_eof_eol_fixeol_bomb(void) +static const char *did_set_eof_eol_fixeol_bomb(optset_T *args FUNC_ATTR_UNUSED) { // redraw the window title and tab page text redraw_titles(); + return NULL; } /// Process the updated 'binary' option value. -static void did_set_binary(int opt_flags, long old_value) +static const char *did_set_binary(optset_T *args) { + buf_T *buf = (buf_T *)args->os_buf; + // when 'bin' is set also set some other options - set_options_bin((int)old_value, curbuf->b_p_bin, opt_flags); + set_options_bin((int)args->os_oldval.boolean, buf->b_p_bin, args->os_flags); redraw_titles(); + + return NULL; } /// Process the updated 'buflisted' option value. -static void did_set_buflisted(long old_value) +static const char *did_set_buflisted(optset_T *args) { + buf_T *buf = (buf_T *)args->os_buf; + // when 'buflisted' changes, trigger autocommands - if (old_value != curbuf->b_p_bl) { - apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, - NULL, NULL, true, curbuf); + if (args->os_oldval.boolean != buf->b_p_bl) { + apply_autocmds(buf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, + NULL, NULL, true, buf); } + return NULL; } /// Process the updated 'swapfile' option value. -static void did_set_swapfile(void) +static const char *did_set_swapfile(optset_T *args) { + buf_T *buf = (buf_T *)args->os_buf; // when 'swf' is set, create swapfile, when reset remove swapfile - if (curbuf->b_p_swf && p_uc) { - ml_open_file(curbuf); // create the swap file + if (buf->b_p_swf && p_uc) { + ml_open_file(buf); // create the swap file } else { // no need to reset curbuf->b_may_swap, ml_open_file() will check // buf->b_p_swf - mf_close_file(curbuf, true); // remove the swap file + mf_close_file(buf, true); // remove the swap file } + return NULL; } /// Process the updated 'paste' option value. -static void did_set_paste(void) +static const char *did_set_paste(optset_T *args FUNC_ATTR_UNUSED) { // when 'paste' is set or reset also change other options paste_option_changed(); + return NULL; } /// Process the updated 'ignorecase' option value. -static void did_set_ignorecase(void) +static const char *did_set_ignorecase(optset_T *args FUNC_ATTR_UNUSED) { // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw if (p_hls) { redraw_all_later(UPD_SOME_VALID); } + return NULL; } /// Process the updated 'hlsearch' option value. -static void did_set_hlsearch(void) +static const char *did_set_hlsearch(optset_T *args FUNC_ATTR_UNUSED) { // when 'hlsearch' is set or reset: reset no_hlsearch set_no_hlsearch(false); + return NULL; } /// Process the updated 'scrollbind' option value. -static void did_set_scrollbind(void) +static const char *did_set_scrollbind(optset_T *args) { + win_T *win = (win_T *)args->os_win; + // when 'scrollbind' is set: snapshot the current position to avoid a jump // at the end of normal_cmd() - if (!curwin->w_p_scb) { - return; + if (!win->w_p_scb) { + return NULL; } do_check_scrollbind(false); - curwin->w_scbind_pos = curwin->w_topline; + win->w_scbind_pos = win->w_topline; + return NULL; } /// Process the updated 'previewwindow' option value. -static const char *did_set_previewwindow(bool *doskip) +static const char *did_set_previewwindow(optset_T *args) { - if (!curwin->w_p_pvw) { + win_T *win = (win_T *)args->os_win; + + if (!win->w_p_pvw) { return NULL; } // There can be only one window with 'previewwindow' set. - FOR_ALL_WINDOWS_IN_TAB(win, curtab) { - if (win->w_p_pvw && win != curwin) { - curwin->w_p_pvw = false; - *doskip = true; + FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { + if (wp->w_p_pvw && wp != win) { + win->w_p_pvw = false; + args->os_doskip = true; return e_preview_window_already_exists; } } @@ -2259,32 +2284,37 @@ static const char *did_set_previewwindow(bool *doskip) } /// Process the updated 'lisp' option value. -static void did_set_lisp(void) +static const char *did_set_lisp(optset_T *args) { + buf_T *buf = (buf_T *)args->os_buf; // When 'lisp' option changes include/exclude '-' in keyword characters. - (void)buf_init_chartab(curbuf, false); // ignore errors + (void)buf_init_chartab(buf, false); // ignore errors + return NULL; } /// Process the updated 'title' or the 'icon' option value. -static void did_set_title_icon(void) +static const char *did_set_title_icon(optset_T *args FUNC_ATTR_UNUSED) { // when 'title' changed, may need to change the title; same for 'icon' did_set_title(); + return NULL; } /// Process the updated 'modified' option value. -static void did_set_modified(long value) +static const char *did_set_modified(optset_T *args) { - if (!value) { - save_file_ff(curbuf); // Buffer is unchanged + buf_T *buf = (buf_T *)args->os_buf; + if (!args->os_newval.boolean) { + save_file_ff(buf); // Buffer is unchanged } redraw_titles(); - modified_was_set = (int)value; + modified_was_set = (int)args->os_newval.boolean; + return NULL; } #ifdef BACKSLASH_IN_FILENAME /// Process the updated 'shellslash' option value. -static void did_set_shellslash(void) +static const char *did_set_shellslash(optset_T *args FUNC_ATTR_UNUSED) { if (p_ssl) { psepc = '/'; @@ -2300,63 +2330,76 @@ static void did_set_shellslash(void) buflist_slash_adjust(); alist_slash_adjust(); scriptnames_slash_adjust(); + return NULL; } #endif /// Process the updated 'wrap' option value. -static void did_set_wrap(void) +static const char *did_set_wrap(optset_T *args) { + win_T *win = (win_T *)args->os_win; + // If 'wrap' is set, set w_leftcol to zero. - if (curwin->w_p_wrap) { - curwin->w_leftcol = 0; + if (win->w_p_wrap) { + win->w_leftcol = 0; } + return NULL; } /// Process the updated 'equalalways' option value. -static void did_set_equalalways(long old_value) +static const char *did_set_equalalways(optset_T *args) { - if (p_ea && !old_value) { - win_equal(curwin, false, 0); + win_T *win = (win_T *)args->os_win; + if (p_ea && !args->os_oldval.boolean) { + win_equal(win, false, 0); } + + return NULL; } /// Process the updated 'autochdir' option value. -static void did_set_autochdir(void) +static const char *did_set_autochdir(optset_T *args FUNC_ATTR_UNUSED) { // Change directories when the 'acd' option is set now. do_autochdir(); + return NULL; } /// Process the updated 'diff' option value. -static void did_set_diff(void) +static const char *did_set_diff(optset_T *args) { + win_T *win = (win_T *)args->os_win; // May add or remove the buffer from the list of diff buffers. - diff_buf_adjust(curwin); - if (foldmethodIsDiff(curwin)) { - foldUpdateAll(curwin); + diff_buf_adjust(win); + if (foldmethodIsDiff(win)) { + foldUpdateAll(win); } + return NULL; } /// Process the updated 'spell' option value. -static char *did_set_spell(void) +static const char *did_set_spell(optset_T *args) { - if (curwin->w_p_spell) { - return did_set_spelllang(curwin); + win_T *win = (win_T *)args->os_win; + if (win->w_p_spell) { + return parse_spelllang(win); } return NULL; } /// Process the updated 'arabic' option value. -static const char *did_set_arabic(void) +static const char *did_set_arabic(optset_T *args) { + win_T *win = (win_T *)args->os_win; const char *errmsg = NULL; - if (curwin->w_p_arab) { + + if (win->w_p_arab) { // 'arabic' is set, handle various sub-settings. if (!p_tbidi) { // set rightleft mode - if (!curwin->w_p_rl) { - curwin->w_p_rl = true; + if (!win->w_p_rl) { + win->w_p_rl = true; changed_window_setting(); } @@ -2386,8 +2429,8 @@ static const char *did_set_arabic(void) // 'arabic' is reset, handle various sub-settings. if (!p_tbidi) { // reset rightleft mode - if (curwin->w_p_rl) { - curwin->w_p_rl = false; + if (win->w_p_rl) { + win->w_p_rl = false; changed_window_setting(); } @@ -2406,85 +2449,15 @@ static const char *did_set_arabic(void) return errmsg; } -static void did_set_number_relativenumber(void) +/// Process the updated 'number' or 'relativenumber' option value. +static const char *did_set_number_relativenumber(optset_T *args) { - if (*curwin->w_p_stc != NUL) { + win_T *win = (win_T *)args->os_win; + if (*win->w_p_stc != NUL) { // When 'relativenumber'/'number' is changed and 'statuscolumn' is set, reset width. - curwin->w_nrwidth_line_count = 0; + win->w_nrwidth_line_count = 0; } -} - -/// When some boolean options are changed, need to take some action. -static const char *did_set_bool_option(const char *varp, int opt_flags, long value, long old_value, - bool *doskip) -{ - const char *errmsg = NULL; - - if ((int *)varp == &p_force_on) { - errmsg = did_set_force_on(doskip); - } else if ((int *)varp == &p_force_off) { - errmsg = did_set_force_off(doskip); - } else if ((int *)varp == &p_lrm) { // 'langremap' - did_set_langremap(); - } else if ((int *)varp == &p_lnr) { // 'langnoremap' - did_set_langnoremap(); - } else if ((int *)varp == &curbuf->b_p_udf // buffer local 'undofile' - || (int *)varp == &p_udf) { // 'undofile' - did_set_undofile(opt_flags); - } else if ((int *)varp == &curbuf->b_p_ro) { // 'readonly' - did_set_readonly(opt_flags); - } else if ((int *)varp == &curbuf->b_p_ma) { - errmsg = did_set_modifiable(); // 'modifiable' - } else if ((int *)varp == &curbuf->b_p_eof // 'endoffile' - || (int *)varp == &curbuf->b_p_eol // 'endofline' - || (int *)varp == &curbuf->b_p_fixeol // 'fixendofline' - || (int *)varp == &curbuf->b_p_bomb) { // 'bomb' - did_set_eof_eol_fixeol_bomb(); - } else if ((int *)varp == &curbuf->b_p_bin) { // 'binary' - did_set_binary(opt_flags, old_value); - } else if ((int *)varp == &curbuf->b_p_bl) { // 'buflisted' - did_set_buflisted(old_value); - } else if ((int *)varp == &curbuf->b_p_swf) { // 'swapfile' - did_set_swapfile(); - } else if ((int *)varp == &p_paste) { // 'paste' - did_set_paste(); - } else if ((int *)varp == &p_ic) { // 'ignorecase' - did_set_ignorecase(); - } else if ((int *)varp == &p_hls) { // 'hlsearch' - did_set_hlsearch(); - } else if ((int *)varp == &curwin->w_p_scb) { // 'scrollbind' - did_set_scrollbind(); - } else if ((int *)varp == &curwin->w_p_pvw) { // 'previewwindow' - errmsg = did_set_previewwindow(doskip); - } else if (varp == (char *)&(curbuf->b_p_lisp)) { // 'lisp' - did_set_lisp(); - } else if ((int *)varp == &p_title // 'title' - || (int *)varp == &p_icon) { // 'icon' - did_set_title_icon(); - } else if ((int *)varp == &curbuf->b_changed) { // 'modified' - did_set_modified(value); -#ifdef BACKSLASH_IN_FILENAME - } else if ((int *)varp == &p_ssl) { // 'shellslash' - did_set_shellslash(); -#endif - } else if ((int *)varp == &curwin->w_p_wrap) { // 'wrap' - did_set_wrap(); - } else if ((int *)varp == &p_ea) { // 'equalalways' - did_set_equalalways(old_value); - } else if ((int *)varp == &p_acd) { // 'autochdir' - did_set_autochdir(); - } else if ((int *)varp == &curwin->w_p_diff) { // 'diff' - did_set_diff(); - } else if ((int *)varp == &curwin->w_p_spell) { // 'spell' - errmsg = did_set_spell(); - } else if ((int *)varp == &curwin->w_p_arab) { // 'arabic' - errmsg = did_set_arabic(); - } else if ((int *)varp == &curwin->w_p_nu // 'number' - || (int *)varp == &curwin->w_p_rnu) { // 'relativenumber' - did_set_number_relativenumber(); - } - - return errmsg; + return NULL; } /// Set the value of a boolean option, taking care of side effects @@ -2524,8 +2497,28 @@ static const char *set_bool_option(const int opt_idx, char *const varp, const in } // Handle side effects for changing a bool option. + const char *errmsg = NULL; bool doskip = false; - const char *errmsg = did_set_bool_option(varp, opt_flags, value, old_value, &doskip); + if ((int *)varp == &p_force_on) { + errmsg = did_set_force_on(&doskip); + } else if ((int *)varp == &p_force_off) { + errmsg = did_set_force_off(&doskip); + } else if (options[opt_idx].opt_did_set_cb != NULL) { + optset_T args = { + .os_varp = varp, + .os_flags = opt_flags, + .os_oldval.boolean = old_value, + .os_newval.boolean = value, + .os_doskip = false, + .os_errbuf = NULL, + .os_errbuflen = 0, + .os_buf = curbuf, + .os_win = curwin + }; + + errmsg = options[opt_idx].opt_did_set_cb(&args); + doskip = args.os_doskip; + } if (doskip) { return errmsg; } @@ -2557,38 +2550,51 @@ static const char *set_bool_option(const int opt_idx, char *const varp, const in } /// Process the new 'winheight' value. -static void did_set_winheight(win_T *win, long value) +static const char *did_set_winheight(optset_T *args) { // Change window height NOW if (!ONE_WINDOW) { - if (win->w_height < value) { - win_setheight((int)value); + win_T *win = (win_T *)args->os_win; + if (win->w_height < p_wh) { + win_setheight((int)p_wh); } } + + return NULL; } /// Process the new 'helpheight' option value. -static void did_set_helpheight(buf_T *buf, win_T *win, long value) +static const char *did_set_helpheight(optset_T *args) { // Change window height NOW if (!ONE_WINDOW) { - if (buf->b_help && win->w_height < value) { - win_setheight((int)value); + buf_T *buf = (buf_T *)args->os_buf; + win_T *win = (win_T *)args->os_win; + if (buf->b_help && win->w_height < p_hh) { + win_setheight((int)p_hh); } } + + return NULL; } /// Process the new 'winwidth' option value. -static void did_set_winwidth(win_T *win, long value) +static const char *did_set_winwidth(optset_T *args) { - if (!ONE_WINDOW && win->w_width < value) { - win_setwidth((int)value); + win_T *win = (win_T *)args->os_win; + + if (!ONE_WINDOW && win->w_width < p_wiw) { + win_setwidth((int)p_wiw); } + return NULL; } /// Process the new 'laststatus' option value. -static void did_set_laststatus(long value, long old_value) +static const char *did_set_laststatus(optset_T *args) { + long old_value = args->os_oldval.number; + long value = args->os_newval.number; + // When switching to global statusline, decrease topframe height // Also clear the cmdline to remove the ruler if there is one if (value == 3 && old_value != 3) { @@ -2604,38 +2610,49 @@ static void did_set_laststatus(long value, long old_value) } last_status(false); // (re)set last window status line. + return NULL; } /// Process the new 'showtabline' option value. -static void did_set_showtabline(void) +static const char *did_set_showtabline(optset_T *args FUNC_ATTR_UNUSED) { // (re)set tab page line win_new_screen_rows(); // recompute window positions and heights + return NULL; } /// Process the new 'foldlevel' option value. -static void did_set_foldlevel(void) +static const char *did_set_foldlevel(optset_T *args FUNC_ATTR_UNUSED) { newFoldLevel(); + return NULL; } /// Process the new 'foldminlines' option value. -static void did_set_foldminlines(win_T *win) +static const char *did_set_foldminlines(optset_T *args) { + win_T *win = (win_T *)args->os_win; foldUpdateAll(win); + return NULL; } /// Process the new 'foldnestmax' option value. -static void did_set_foldnestmax(win_T *win) +static const char *did_set_foldnestmax(optset_T |