summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-07-10 20:27:32 +0200
committerBram Moolenaar <Bram@vim.org>2016-07-10 20:27:32 +0200
commitea3f2e7be447a8f0c4436869620f908de5e8ef1e (patch)
tree45f63c4ce1a6641183ddc7791b8553e93f887c40
parent25065ec375a8a55462f6c07c76dc1a72a770ac19 (diff)
downloadvim-git-ea3f2e7be447a8f0c4436869620f908de5e8ef1e.tar.gz
patch 7.4.2023v7.4.2023
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.
-rw-r--r--src/buffer.c8
-rw-r--r--src/quickfix.c4
-rw-r--r--src/version.c2
3 files changed, 11 insertions, 3 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 409564b96..903a94aeb 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -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;
diff --git a/src/quickfix.c b/src/quickfix.c
index 1e5abc69e..24852b366 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -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;
}
/*
diff --git a/src/version.c b/src/version.c
index c9febf7c9..913bf6966 100644
--- a/src/version.c
+++ b/src/version.c
@@ -759,6 +759,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2023,
+/**/
2022,
/**/
2021,