mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Problem: 'balloonexpr' is evaluated in the current script context. Solution: Use the script context where the option was set.
This commit is contained in:
13
src/beval.c
13
src/beval.c
@@ -259,6 +259,8 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
|
|||||||
: wp->w_buffer->b_p_bexpr;
|
: wp->w_buffer->b_p_bexpr;
|
||||||
if (*bexpr != NUL)
|
if (*bexpr != NUL)
|
||||||
{
|
{
|
||||||
|
sctx_T save_sctx = current_sctx;
|
||||||
|
|
||||||
// Convert window pointer to number.
|
// Convert window pointer to number.
|
||||||
for (cw = firstwin; cw != wp; cw = cw->w_next)
|
for (cw = firstwin; cw != wp; cw = cw->w_next)
|
||||||
++winnr;
|
++winnr;
|
||||||
@@ -284,6 +286,16 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
|
|||||||
++sandbox;
|
++sandbox;
|
||||||
++textwinlock;
|
++textwinlock;
|
||||||
|
|
||||||
|
if (bexpr == p_bexpr)
|
||||||
|
{
|
||||||
|
sctx_T *sp = get_option_sctx("balloonexpr");
|
||||||
|
|
||||||
|
if (sp != NULL)
|
||||||
|
current_sctx = *sp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
current_sctx = curbuf->b_p_script_ctx[BV_BEXPR];
|
||||||
|
|
||||||
vim_free(result);
|
vim_free(result);
|
||||||
result = eval_to_string(bexpr, TRUE);
|
result = eval_to_string(bexpr, TRUE);
|
||||||
|
|
||||||
@@ -300,6 +312,7 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
|
|||||||
if (use_sandbox)
|
if (use_sandbox)
|
||||||
--sandbox;
|
--sandbox;
|
||||||
--textwinlock;
|
--textwinlock;
|
||||||
|
current_sctx = save_sctx;
|
||||||
|
|
||||||
set_vim_var_string(VV_BEVAL_TEXT, NULL, -1);
|
set_vim_var_string(VV_BEVAL_TEXT, NULL, -1);
|
||||||
if (result != NULL && result[0] != NUL)
|
if (result != NULL && result[0] != NUL)
|
||||||
|
15
src/option.c
15
src/option.c
@@ -2614,6 +2614,21 @@ set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the script context of global option "name".
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
sctx_T *
|
||||||
|
get_option_sctx(char *name)
|
||||||
|
{
|
||||||
|
int idx = findoption((char_u *)name);
|
||||||
|
|
||||||
|
if (idx >= 0)
|
||||||
|
return &options[idx].script_ctx;
|
||||||
|
siemsg("no such option: %s", name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the script_ctx for a termcap option.
|
* Set the script_ctx for a termcap option.
|
||||||
* "name" must be the two character code, e.g. "RV".
|
* "name" must be the two character code, e.g. "RV".
|
||||||
|
@@ -22,6 +22,7 @@ int was_set_insecurely(char_u *opt, int opt_flags);
|
|||||||
void redraw_titles(void);
|
void redraw_titles(void);
|
||||||
int valid_name(char_u *val, char *allowed);
|
int valid_name(char_u *val, char *allowed);
|
||||||
void set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx);
|
void set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx);
|
||||||
|
sctx_T *get_option_sctx(char *name);
|
||||||
void set_term_option_sctx_idx(char *name, int opt_idx);
|
void set_term_option_sctx_idx(char *name, int opt_idx);
|
||||||
void check_redraw(long_u flags);
|
void check_redraw(long_u flags);
|
||||||
int findoption(char_u *arg);
|
int findoption(char_u *arg);
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|t|w|o| |t|X|o| |t|w|o| @38
|
|t|w|o| |t|X|o| |t|w|o| @38
|
||||||
|t|h|r|e| +0#0000001#ffd7ff255@17| +0#0000000#ffffff0@27
|
|t|h|r|e| +0#0000001#ffd7ff255@17| +0#0000000#ffffff0@27
|
||||||
|~+0#4040ff13&| @2| +0#0000001#ffd7ff255|l|i|n|e| |2| |c|o|l|u|m|n| |6|:| | +0#4040ff13#ffffff0@27
|
|~+0#4040ff13&| @2| +0#0000001#ffd7ff255|l|i|n|e| |2| |c|o|l|u|m|n| |6|:| | +0#4040ff13#ffffff0@27
|
||||||
|~| @2| +0#0000001#ffd7ff255|t|X|o| @13| +0#4040ff13#ffffff0@27
|
|~| @2| +0#0000001#ffd7ff255|t|X|o|<| @12| +0#4040ff13#ffffff0@27
|
||||||
|~| @2| +0#0000001#ffd7ff255@17| +0#4040ff13#ffffff0@27
|
|~| @2| +0#0000001#ffd7ff255@17| +0#4040ff13#ffffff0@27
|
||||||
|~| @48
|
|~| @48
|
||||||
|~| @48
|
|~| @48
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|t|w|o| |t|X|o| |t|w|o| @38
|
|t|w|o| |t|X|o| |t|w|o| @38
|
||||||
|t|h|r|e| +0#0000001#ffd7ff255@17| +0#0000000#ffffff0@27
|
|t|h|r|e| +0#0000001#ffd7ff255@17| +0#0000000#ffffff0@27
|
||||||
|~+0#4040ff13&| @2| +0#0000001#ffd7ff255|l|i|n|e| |2| |c|o|l|u|m|n| |6|:| | +0#4040ff13#ffffff0@27
|
|~+0#4040ff13&| @2| +0#0000001#ffd7ff255|l|i|n|e| |2| |c|o|l|u|m|n| |6|:| | +0#4040ff13#ffffff0@27
|
||||||
|~| @2| +0#0000001#ffd7ff255|t|X|o| @13| +0#4040ff13#ffffff0@27
|
|~| @2| +0#0000001#ffd7ff255|t|X|o|<| @12| +0#4040ff13#ffffff0@27
|
||||||
|~| @2| +0#0000001#ffd7ff255@17| +0#4040ff13#ffffff0@27
|
|~| @2| +0#0000001#ffd7ff255@17| +0#4040ff13#ffffff0@27
|
||||||
|~| @48
|
|~| @48
|
||||||
|~| @48
|
|~| @48
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
|t|h|r|e|e+0&#e0e0e08| |t|h>r+0&#ffffff0|e@1| |t|h|r|e@1| @32
|
|t|h|r|e|e+0&#e0e0e08| |t|h>r+0&#ffffff0|e@1| |t|h|r|e@1| @32
|
||||||
|~+0#4040ff13&| @2| +0#0000001#ffd7ff255@17| +0#4040ff13#ffffff0@27
|
|~+0#4040ff13&| @2| +0#0000001#ffd7ff255@17| +0#4040ff13#ffffff0@27
|
||||||
|~| @2| +0#0000001#ffd7ff255|l|i|n|e| |3| |c|o|l|u|m|n| |5|:| | +0#4040ff13#ffffff0@27
|
|~| @2| +0#0000001#ffd7ff255|l|i|n|e| |3| |c|o|l|u|m|n| |5|:| | +0#4040ff13#ffffff0@27
|
||||||
|~| @2| +0#0000001#ffd7ff255|e| |t|h|r| @11| +0#4040ff13#ffffff0@27
|
|~| @2| +0#0000001#ffd7ff255|e| |t|h|r|<| @10| +0#4040ff13#ffffff0@27
|
||||||
|~| @2| +0#0000001#ffd7ff255@17| +0#4040ff13#ffffff0@27
|
|~| @2| +0#0000001#ffd7ff255@17| +0#4040ff13#ffffff0@27
|
||||||
|~| @48
|
|~| @48
|
||||||
|~| @48
|
|~| @48
|
||||||
|
@@ -10,7 +10,8 @@ CheckScreendump
|
|||||||
|
|
||||||
let s:common_script =<< trim [CODE]
|
let s:common_script =<< trim [CODE]
|
||||||
call setline(1, ["one one one", "two tXo two", "three three three"])
|
call setline(1, ["one one one", "two tXo two", "three three three"])
|
||||||
set balloonevalterm balloonexpr=MyBalloonExpr() balloondelay=100
|
set balloonevalterm balloonexpr=MyBalloonExpr()..s:trailing balloondelay=100
|
||||||
|
let s:trailing = '<' " check that script context is set
|
||||||
func MyBalloonExpr()
|
func MyBalloonExpr()
|
||||||
return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ":\n" .. v:beval_text
|
return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ":\n" .. v:beval_text
|
||||||
endfun
|
endfun
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4180,
|
||||||
/**/
|
/**/
|
||||||
4179,
|
4179,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user