]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0066: switching window uneccarily when getting buffer options v9.0.0066
authorzeertzjq <zeertzjq@outlook.com>
Mon, 25 Jul 2022 11:28:09 +0000 (12:28 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 25 Jul 2022 11:28:09 +0000 (12:28 +0100)
Problem:    Switching window uneccarily when getting buffer options.
Solution:   Do not switch window when getting buffer options. (closes #10767)

src/evalvars.c
src/version.c

index 779627c45a98d0031947780d787405a32c726a03..d4e8d29e8a03cba30d58797f20e1caba9b5b0aaf 100644 (file)
@@ -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)
index 364a0714396b641eea57e002866b068a26fc141d..3b0f70e89e88a1239f12d3e51a758e8a43035fe7 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    66,
 /**/
     65,
 /**/