commit 5d3ad6fd9031040da856167d4672154149625e8f
parent 96451e7f606947c33b11ca024fa76dedf47314b1
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon, 17 Apr 2023 15:24:40 +0800
vim-patch:8.2.4185: cannot use an import in 'indentexpr'
Problem: Cannot use an import in 'indentexpr'.
Solution: Set the script context when evaluating 'indentexpr'
https://github.com/vim/vim/commit/28e60cc088cadd25afb69ee636f0e2e34233ba4e
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
@@ -1122,6 +1122,7 @@ int get_expr_indent(void)
int save_set_curswant;
int save_State;
int use_sandbox = was_set_insecurely(curwin, "indentexpr", OPT_LOCAL);
+ const sctx_T save_sctx = current_sctx;
// Save and restore cursor position and curswant, in case it was changed
// * via :normal commands.
@@ -1134,6 +1135,7 @@ int get_expr_indent(void)
sandbox++;
}
textlock++;
+ current_sctx = curbuf->b_p_script_ctx[BV_INDE].script_ctx;
// Need to make a copy, the 'indentexpr' option could be changed while
// evaluating it.
@@ -1145,6 +1147,7 @@ int get_expr_indent(void)
sandbox--;
}
textlock--;
+ current_sctx = save_sctx;
// Restore the cursor position so that 'indentexpr' doesn't need to.
// Pretend to be in Insert mode, allow cursor past end of line for "o"