]> granicus.if.org Git - vim/commitdiff
patch 7.4.2023 v7.4.2023
authorBram Moolenaar <Bram@vim.org>
Sun, 10 Jul 2016 18:27:32 +0000 (20:27 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 10 Jul 2016 18:27:32 +0000 (20:27 +0200)
Problem:    buflist_findname_stat() may find a dummy buffer.
Solution:   Set the BF_DUMMY flag after loading a dummy buffer.  Start
            finding buffers from the end of the list.

src/buffer.c
src/quickfix.c
src/version.c

index 409564b96656af60e0173baf6344f7c7f78b38ba..903a94aebf1fd0ead988e3bd372c1ed0d1c34f08 100644 (file)
@@ -2270,7 +2270,8 @@ buflist_findname_stat(
 #endif
     buf_T      *buf;
 
-    for (buf = firstbuf; buf != NULL; buf = buf->b_next)
+    /* Start at the last buffer, expect to find a match sooner. */
+    for (buf = lastbuf; buf != NULL; buf = buf->b_prev)
        if ((buf->b_flags & BF_DUMMY) == 0 && !otherfile_buf(buf, ffname
 #ifdef UNIX
                    , stp
@@ -2355,7 +2356,7 @@ buflist_findpat(
                    return -1;
                }
 
-               for (buf = firstbuf; buf != NULL; buf = buf->b_next)
+               for (buf = lastbuf; buf != NULL; buf = buf->b_prev)
                    if (buf->b_p_bl == find_listed
 #ifdef FEAT_DIFF
                            && (!diffmode || diff_mode_buf(buf))
@@ -2581,7 +2582,8 @@ buflist_findnr(int nr)
 
     if (nr == 0)
        nr = curwin->w_alt_fnum;
-    for (buf = firstbuf; buf != NULL; buf = buf->b_next)
+    /* Assume newer buffers are used more often, start from the end. */
+    for (buf = lastbuf; buf != NULL; buf = buf->b_prev)
        if (buf->b_fnum == nr)
            return buf;
     return NULL;
index 1e5abc69e600f90c92d8ac70fc97713a4ceab9f7..24852b366e93bc4a3c01e303c148a1d3c41f5249 100644 (file)
@@ -4292,6 +4292,10 @@ load_dummy_buffer(
        aucmd_restbuf(&aco);
        if (newbuf_to_wipe != NULL && buf_valid(newbuf_to_wipe))
            wipe_buffer(newbuf_to_wipe, FALSE);
+
+       /* Add back the "dummy" flag, otherwise buflist_findname_stat() won't
+        * skip it. */
+       newbuf->b_flags |= BF_DUMMY;
     }
 
     /*
index c9febf7c941848b4e7a624e32966089c73bbd0f5..913bf69661903ac1e7b4d0b405319f85e8300733 100644 (file)
@@ -758,6 +758,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2023,
 /**/
     2022,
 /**/