Patch 8.1.2418
Problem: bufnr('$') is wrong after recycling popup buffer.
Solution: Sort the buffer list by buffer number. (closes #5335)
Files: src/buffer.c, src/testdir/test_popupwin.vim
*** ../vim-8.1.2417/src/buffer.c 2019-11-30 22:47:42.639331256 +0100
--- src/buffer.c 2019-12-10 23:33:04.567469510 +0100
***************
*** 2093,2098 ****
--- 2093,2117 ----
// 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++;
*** ../vim-8.1.2417/src/testdir/test_popupwin.vim 2019-12-06
20:17:20.379094586 +0100
--- src/testdir/test_popupwin.vim 2019-12-10 23:10:17.273669168 +0100
***************
*** 3168,3171 ****
--- 3168,3188 ----
call delete('XtestPopupSign')
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-8.1.2417/src/version.c 2019-12-10 22:48:08.368051992 +0100
--- src/version.c 2019-12-10 23:12:08.957119998 +0100
***************
*** 744,745 ****
--- 744,747 ----
{ /* Add new patch number below this line */
+ /**/
+ 2418,
/**/
--
hundred-and-one symptoms of being an internet addict:
244. You use more than 20 passwords.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/201912102245.xBAMjYjS022295%40masaka.moolenaar.net.