aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-17 15:25:34 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-04-17 15:46:24 +0800
commitcec42e07bc136f496135dfd8ed6e6c4d16a24e0d (patch)
treecc9a2d54c59fef3dafa5321d26cd7da5e72283f4
parent5d3ad6fd9031040da856167d4672154149625e8f (diff)
downloadrneovim-cec42e07bc136f496135dfd8ed6e6c4d16a24e0d.tar.gz
rneovim-cec42e07bc136f496135dfd8ed6e6c4d16a24e0d.tar.bz2
rneovim-cec42e07bc136f496135dfd8ed6e6c4d16a24e0d.zip
vim-patch:8.2.4186: cannot use an import in 'patchexpr'
Problem: Cannot use an import in 'patchexpr'. Solution: Set the script context when evaluating 'patchexpr'. Do not require 'patchexpr' to return a bool, it was ignored anyway. https://github.com/vim/vim/commit/36c2add7f82bc5dbbfc45db31953ef9633c635b3 Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--src/nvim/eval.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 750d9df454..9a94d414f9 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -691,15 +691,24 @@ void eval_diff(const char *const origfile, const char *const newfile, const char
void eval_patch(const char *const origfile, const char *const difffile, const char *const outfile)
{
- bool err = false;
-
+ const sctx_T saved_sctx = current_sctx;
set_vim_var_string(VV_FNAME_IN, origfile, -1);
set_vim_var_string(VV_FNAME_DIFF, difffile, -1);
set_vim_var_string(VV_FNAME_OUT, outfile, -1);
- (void)eval_to_bool(p_pex, &err, NULL, false);
+
+ sctx_T *ctx = get_option_sctx("patchexpr");
+ if (ctx != NULL) {
+ current_sctx = *ctx;
+ }
+
+ // errors are ignored
+ typval_T *tv = eval_expr(p_pex, NULL);
+ tv_free(tv);
+
set_vim_var_string(VV_FNAME_IN, NULL, -1);
set_vim_var_string(VV_FNAME_DIFF, NULL, -1);
set_vim_var_string(VV_FNAME_OUT, NULL, -1);
+ current_sctx = saved_sctx;
}
void fill_evalarg_from_eap(evalarg_T *evalarg, exarg_T *eap, bool skip)