forked from aniani/vim
patch 8.2.4183: cannot use an import in 'formatexpr'
Problem: Cannot use an import in 'formatexpr'. Solution: Set the script context when evaluating 'formatexpr'.
This commit is contained in:
@@ -903,6 +903,7 @@ fex_format(
|
||||
OPT_LOCAL);
|
||||
int r;
|
||||
char_u *fex;
|
||||
sctx_T save_sctx = current_sctx;
|
||||
|
||||
// Set v:lnum to the first line number and v:count to the number of lines.
|
||||
// Set v:char to the character to be inserted (can be NUL).
|
||||
@@ -914,6 +915,7 @@ fex_format(
|
||||
fex = vim_strsave(curbuf->b_p_fex);
|
||||
if (fex == NULL)
|
||||
return 0;
|
||||
current_sctx = curbuf->b_p_script_ctx[BV_FEX];
|
||||
|
||||
// Evaluate the function.
|
||||
if (use_sandbox)
|
||||
@@ -924,6 +926,7 @@ fex_format(
|
||||
|
||||
set_vim_var_string(VV_CHAR, NULL, -1);
|
||||
vim_free(fex);
|
||||
current_sctx = save_sctx;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
Reference in New Issue
Block a user