diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2022-12-03 09:05:20 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-03 09:05:20 +0800 |
| commit | c0840087c83175267667a355131d4dffccfd8ff5 (patch) | |
| tree | be47cfc360ca4f467228d2c900fe5202bd6693a5 /src/nvim/optionstr.c | |
| parent | 10c50d9f30138e7811789ba1c62f4c520cf04c8f (diff) | |
| parent | 5e97984188e95de419ba5a710a060f0614c6c9e0 (diff) | |
| download | rneovim-c0840087c83175267667a355131d4dffccfd8ff5.tar.gz rneovim-c0840087c83175267667a355131d4dffccfd8ff5.tar.bz2 rneovim-c0840087c83175267667a355131d4dffccfd8ff5.zip | |
Merge pull request #21267 from zeertzjq/vim-8.2.3900
vim-patch:8.2.{3900,partial:3908}: it is not easy to use a script-local function for an option
Diffstat (limited to 'src/nvim/optionstr.c')
| -rw-r--r-- | src/nvim/optionstr.c | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 61a51532a4..cd87db9aa9 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -17,6 +17,7 @@ #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" +#include "nvim/eval/userfunc.h" #include "nvim/eval/vars.h" #include "nvim/ex_getln.h" #include "nvim/fold.h" @@ -1341,10 +1342,6 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf newFoldLevel(); } } - } else if (varp == &curwin->w_p_fde) { // 'foldexpr' - if (foldmethodIsExpr(curwin)) { - foldUpdateAll(curwin); - } } else if (gvarp == &curwin->w_allbuf_opt.wo_fmr) { // 'foldmarker' p = vim_strchr(*varp, ','); if (p == NULL) { @@ -1484,6 +1481,55 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf } } } + } else if (varp == &p_dex + || varp == &curwin->w_p_fde + || varp == &curwin->w_p_fdt + || gvarp == &p_fex + || gvarp == &p_inex + || gvarp == &p_inde + || varp == &p_pex + || varp == &p_pexpr) { // '*expr' options + char **p_opt = NULL; + + // If the option value starts with <SID> or s:, then replace that with + // the script identifier. + + if (varp == &p_dex) { // 'diffexpr' + p_opt = &p_dex; + } + if (varp == &curwin->w_p_fde) { // 'foldexpr' + p_opt = &curwin->w_p_fde; + } + if (varp == &curwin->w_p_fdt) { // 'foldtext' + p_opt = &curwin->w_p_fdt; + } + if (gvarp == &p_fex) { // 'formatexpr' + p_opt = &curbuf->b_p_fex; + } + if (gvarp == &p_inex) { // 'includeexpr' + p_opt = &curbuf->b_p_inex; + } + if (gvarp == &p_inde) { // 'indentexpr' + p_opt = &curbuf->b_p_inde; + } + if (varp == &p_pex) { // 'patchexpr' + p_opt = &p_pex; + } + if (varp == &p_pexpr) { // 'printexpr' + p_opt = &p_pexpr; + } + + if (p_opt != NULL) { + char *name = get_scriptlocal_funcname(*p_opt); + if (name != NULL) { + free_string_option(*p_opt); + *p_opt = name; + } + } + + if (varp == &curwin->w_p_fde && foldmethodIsExpr(curwin)) { + foldUpdateAll(curwin); + } } else if (gvarp == &p_cfu) { // 'completefunc' if (set_completefunc_option() == FAIL) { errmsg = e_invarg; |
