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:
19
src/buffer.c
19
src/buffer.c
@@ -2093,6 +2093,25 @@ buflist_new(
|
|||||||
// buffer number grows rapidly.
|
// buffer number grows rapidly.
|
||||||
--buf_reuse.ga_len;
|
--buf_reuse.ga_len;
|
||||||
buf->b_fnum = ((int *)buf_reuse.ga_data)[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
|
else
|
||||||
buf->b_fnum = top_file_num++;
|
buf->b_fnum = top_file_num++;
|
||||||
|
@@ -3168,4 +3168,21 @@ func Test_popupwin_sign()
|
|||||||
call delete('XtestPopupSign')
|
call delete('XtestPopupSign')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_popupwin_bufnr()
|
||||||
|
let popwin = popup_create(['blah'], #{})
|
||||||
|
let popbuf = winbufnr(popwin)
|
||||||
|
split asdfasdf
|
||||||
|
let newbuf = bufnr()
|
||||||
|
call assert_true(newbuf > popbuf, 'New buffer number is higher')
|
||||||
|
call assert_equal(newbuf, bufnr('$'))
|
||||||
|
call popup_clear()
|
||||||
|
let popwin = popup_create(['blah'], #{})
|
||||||
|
" reuses previous buffer number
|
||||||
|
call assert_equal(popbuf, winbufnr(popwin))
|
||||||
|
call assert_equal(newbuf, bufnr('$'))
|
||||||
|
|
||||||
|
call popup_clear()
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2
|
" vim: shiftwidth=2 sts=2
|
||||||
|
@@ -742,6 +742,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2418,
|
||||||
/**/
|
/**/
|
||||||
2417,
|
2417,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user