0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.1.2418: bufnr('$') is wrong after recycling popup buffer

Problem:    bufnr('$') is wrong after recycling popup buffer.
Solution:   Sort the buffer list by buffer number. (closes #5335)
This commit is contained in:
Bram Moolenaar
2019-12-10 23:44:48 +01:00
parent 1e46705a83
commit 99ebf22c52
3 changed files with 38 additions and 0 deletions

View File

@@ -2093,6 +2093,25 @@ buflist_new(
// buffer number grows rapidly.
--buf_reuse.ga_len;
buf->b_fnum = ((int *)buf_reuse.ga_data)[buf_reuse.ga_len];
// Move buffer to the right place in the buffer list.
while (buf->b_prev != NULL && buf->b_fnum < buf->b_prev->b_fnum)
{
buf_T *prev = buf->b_prev;
prev->b_next = buf->b_next;
if (prev->b_next != NULL)
prev->b_next->b_prev = prev;
buf->b_next = prev;
buf->b_prev = prev->b_prev;
if (buf->b_prev != NULL)
buf->b_prev->b_next = buf;
prev->b_prev = buf;
if (lastbuf == buf)
lastbuf = prev;
if (firstbuf == prev)
firstbuf = buf;
}
}
else
buf->b_fnum = top_file_num++;