diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-04-17 15:17:58 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-04-17 15:46:24 +0800 |
commit | ba57566601725c5ac142a77b42d45d8d7f02a243 (patch) | |
tree | 3fc33c4500b271878e4fcd8562b42a6469d59218 | |
parent | 0c99ae7a88216f32ad188fc67ed00387c6ce2cae (diff) | |
download | rneovim-ba57566601725c5ac142a77b42d45d8d7f02a243.tar.gz rneovim-ba57566601725c5ac142a77b42d45d8d7f02a243.tar.bz2 rneovim-ba57566601725c5ac142a77b42d45d8d7f02a243.zip |
vim-patch:8.2.4181: Vim9: cannot use an import in 'diffexpr'
Problem: Vim9: cannot use an import in 'diffexpr'.
Solution: Set the script context when evaluating 'diffexpr'. Do not require
'diffexpr' to return a bool, it was ignored anyway.
https://github.com/vim/vim/commit/7b29f6a3949743914f08410b6f6bd6237c2f2038
Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r-- | src/nvim/eval.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 8d38df8421..5eb7e2260f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -669,15 +669,24 @@ int eval_charconvert(const char *const enc_from, const char *const enc_to, void eval_diff(const char *const origfile, const char *const newfile, 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_NEW, newfile, -1); set_vim_var_string(VV_FNAME_OUT, outfile, -1); - (void)eval_to_bool(p_dex, &err, NULL, false); + + sctx_T *ctx = get_option_sctx("diffexpr"); + if (ctx != NULL) { + current_sctx = *ctx; + } + + // errors are ignored + typval_T *tv = eval_expr(p_dex, NULL); + tv_clear(tv); + set_vim_var_string(VV_FNAME_IN, NULL, -1); set_vim_var_string(VV_FNAME_NEW, NULL, -1); set_vim_var_string(VV_FNAME_OUT, NULL, -1); + current_sctx = saved_sctx; } void eval_patch(const char *const origfile, const char *const difffile, const char *const outfile) |