diff options
-rw-r--r-- | src/nvim/buffer.c | 5 | ||||
-rw-r--r-- | src/nvim/globals.h | 5 | ||||
-rw-r--r-- | src/nvim/quickfix.c | 11 | ||||
-rw-r--r-- | src/nvim/version.c | 4 |
4 files changed, 17 insertions, 8 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 81dceacd37..9204357fee 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1849,7 +1849,8 @@ buf_T *buflist_findname(char_u *ffname) static buf_T *buflist_findname_file_id(char_u *ffname, FileID *file_id, bool file_id_valid) { - FOR_ALL_BUFFERS(buf) { + // Start at the last buffer, expect to find a match sooner. + FOR_ALL_BUFFERS_BACKWARDS(buf) { if ((buf->b_flags & BF_DUMMY) == 0 && !otherfile_buf(buf, ffname, file_id, file_id_valid)) { return buf; @@ -1923,7 +1924,7 @@ int buflist_findpat( return -1; } - FOR_ALL_BUFFERS(buf) { + FOR_ALL_BUFFERS_BACKWARDS(buf) { if (buf->b_p_bl == find_listed && (!diffmode || diff_mode_buf(buf)) && buflist_match(®match, buf, false) != NULL) { diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 0a47eaaef2..9da6062ffb 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -602,7 +602,10 @@ EXTERN buf_T *lastbuf INIT(= NULL); // last buffer EXTERN buf_T *curbuf INIT(= NULL); // currently active buffer // Iterates over all buffers in the buffer list. -# define FOR_ALL_BUFFERS(buf) for (buf_T *buf = firstbuf; buf != NULL; buf = buf->b_next) +#define FOR_ALL_BUFFERS(buf) \ + for (buf_T *buf = firstbuf; buf != NULL; buf = buf->b_next) +#define FOR_ALL_BUFFERS_BACKWARDS(buf) \ + for (buf_T *buf = lastbuf; buf != NULL; buf = buf->b_prev) /* Flag that is set when switching off 'swapfile'. It means that all blocks * are to be loaded into memory. Shouldn't be global... */ diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 4e582108c5..45982cc68a 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3778,10 +3778,15 @@ load_dummy_buffer ( } } - /* restore curwin/curbuf and a few other things */ + // Restore curwin/curbuf and a few other things. aucmd_restbuf(&aco); - if (newbuf_to_wipe != NULL && buf_valid(newbuf_to_wipe)) - wipe_buffer(newbuf_to_wipe, FALSE); + if (newbuf_to_wipe != NULL && buf_valid(newbuf_to_wipe)) { + wipe_buffer(newbuf_to_wipe, false); + } + + // Add back the "dummy" flag, otherwise buflist_findname_file_id() + // won't skip it. + newbuf->b_flags |= BF_DUMMY; } /* diff --git a/src/nvim/version.c b/src/nvim/version.c index 658b553ec0..e73b68b6e7 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -416,8 +416,8 @@ static int included_patches[] = { // 2027 NA // 2026 NA // 2025 NA - // 2024, - // 2023, + 2024, + 2023, 2022, 2021, // 2020 NA |