From 5d3ad6fd9031040da856167d4672154149625e8f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 17 Apr 2023 15:24:40 +0800 Subject: 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 --- src/nvim/indent.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 8a65e88545..1d8bceae4e 100644 --- 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" -- cgit