summaryrefslogtreecommitdiffstats
path: root/src/evalvars.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-25 12:28:09 +0100
committerBram Moolenaar <Bram@vim.org>2022-07-25 12:28:09 +0100
commitcd6ad6439da2ee2d1a8a6934c9d69e9c2664ba55 (patch)
tree2ba97df8d1ee3651a14d3bbe5c18084c47978433 /src/evalvars.c
parent509695c1c3f5c94bf4b1de5dd0fc11202804f638 (diff)
patch 9.0.0066: switching window uneccarily when getting buffer optionsv9.0.0066
Problem: Switching window uneccarily when getting buffer options. Solution: Do not switch window when getting buffer options. (closes #10767)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r--src/evalvars.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index 779627c45a..d4e8d29e8a 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -4098,6 +4098,7 @@ get_var_from(
int done = FALSE;
switchwin_T switchwin;
int need_switch_win;
+ int do_change_curbuf = buf != NULL && htname == 'b';
++emsg_off;
@@ -4112,7 +4113,7 @@ get_var_from(
// autocommands get blocked.
// If we have a buffer reference avoid the switching, we're saving and
// restoring curbuf directly.
- need_switch_win = !(tp == curtab && win == curwin) || (buf != NULL);
+ need_switch_win = !(tp == curtab && win == curwin) && !do_change_curbuf;
if (!need_switch_win || switch_win(&switchwin, win, tp, TRUE) == OK)
{
// Handle options. There are no tab-local options.
@@ -4121,12 +4122,12 @@ get_var_from(
buf_T *save_curbuf = curbuf;
// Change curbuf so the option is read from the correct buffer.
- if (buf != NULL && htname == 'b')
+ if (do_change_curbuf)
curbuf = buf;
if (varname[1] == NUL)
{
- // get all window-local options in a dict
+ // get all window-local or buffer-local options in a dict
dict_T *opts = get_winbuf_options(htname == 'b');
if (opts != NULL)