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'

28e60cc088

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-04-17 15:24:40 +08:00
parent 96451e7f60
commit 5d3ad6fd90

View File

@@ -1122,6 +1122,7 @@ int get_expr_indent(void)
int save_set_curswant; int save_set_curswant;
int save_State; int save_State;
int use_sandbox = was_set_insecurely(curwin, "indentexpr", OPT_LOCAL); 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 // Save and restore cursor position and curswant, in case it was changed
// * via :normal commands. // * via :normal commands.
@@ -1134,6 +1135,7 @@ int get_expr_indent(void)
sandbox++; sandbox++;
} }
textlock++; textlock++;
current_sctx = curbuf->b_p_script_ctx[BV_INDE].script_ctx;
// Need to make a copy, the 'indentexpr' option could be changed while // Need to make a copy, the 'indentexpr' option could be changed while
// evaluating it. // evaluating it.
@@ -1145,6 +1147,7 @@ int get_expr_indent(void)
sandbox--; sandbox--;
} }
textlock--; textlock--;
current_sctx = save_sctx;
// Restore the cursor position so that 'indentexpr' doesn't need to. // 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" // Pretend to be in Insert mode, allow cursor past end of line for "o"