diff src/beval.c @ 27303:9e0ac05f579a v8.2.4180

patch 8.2.4180: 'balloonexpr' is evaluated in the current script context Commit: https://github.com/vim/vim/commit/5600a709f453045c80f92087acc0f855b4af377a Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 22 15:09:36 2022 +0000 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.
author Bram Moolenaar <Bram@vim.org>
date Sat, 22 Jan 2022 16:15:02 +0100
parents d413104a94c8
children 45c182c4f7e9
line wrap: on
line diff
--- a/src/beval.c
+++ b/src/beval.c
@@ -259,6 +259,8 @@ general_beval_cb(BalloonEval *beval, int
 						    : wp->w_buffer->b_p_bexpr;
 	if (*bexpr != NUL)
 	{
+	    sctx_T	save_sctx = current_sctx;
+
 	    // Convert window pointer to number.
 	    for (cw = firstwin; cw != wp; cw = cw->w_next)
 		++winnr;
@@ -284,6 +286,16 @@ general_beval_cb(BalloonEval *beval, int
 		++sandbox;
 	    ++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);
 	    result = eval_to_string(bexpr, TRUE);
 
@@ -300,6 +312,7 @@ general_beval_cb(BalloonEval *beval, int
 	    if (use_sandbox)
 		--sandbox;
 	    --textwinlock;
+	    current_sctx = save_sctx;
 
 	    set_vim_var_string(VV_BEVAL_TEXT, NULL, -1);
 	    if (result != NULL && result[0] != NUL)