diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-07-25 19:31:55 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-07-25 20:01:59 +0800 |
commit | ad57610ac7ad3a52e1de42c9dc446acf48fadbb6 (patch) | |
tree | efbe614e213e64393a5901528fae4813bbdb0b0f | |
parent | 56ed5a040303ecb30aa50c8bde545e5e47862271 (diff) | |
download | rneovim-ad57610ac7ad3a52e1de42c9dc446acf48fadbb6.tar.gz rneovim-ad57610ac7ad3a52e1de42c9dc446acf48fadbb6.tar.bz2 rneovim-ad57610ac7ad3a52e1de42c9dc446acf48fadbb6.zip |
vim-patch:9.0.0066: switching window uneccarily when getting buffer options
Problem: Switching window uneccarily when getting buffer options.
Solution: Do not switch window when getting buffer options. (closes vim/vim#10767)
https://github.com/vim/vim/commit/cd6ad6439da2ee2d1a8a6934c9d69e9c2664ba55
-rw-r--r-- | src/nvim/eval/vars.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index a0e4bfd6a3..190cc62d85 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -1506,6 +1506,7 @@ static void get_var_from(const char *varname, typval_T *rettv, typval_T *deftv, tabpage_T *tp, win_T *win, buf_T *buf) { bool done = false; + const bool do_change_curbuf = buf != NULL && htname == 'b'; emsg_off++; @@ -1518,19 +1519,19 @@ static void get_var_from(const char *varname, typval_T *rettv, typval_T *deftv, // autocommands get blocked. // If we have a buffer reference avoid the switching, we're saving and // restoring curbuf directly. - const bool need_switch_win = !(tp == curtab && win == curwin) || (buf != NULL); + const bool need_switch_win = !(tp == curtab && win == curwin) && !do_change_curbuf; switchwin_T switchwin; if (!need_switch_win || switch_win(&switchwin, win, tp, true) == OK) { if (*varname == '&' && htname != 't') { buf_T *const 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) { |