Patch 8.2.4791

6 views
Skip to first unread message

Bram Moolenaar

unread,
Apr 19, 2022, 11:24:52 AM4/19/22
to vim...@googlegroups.com

Patch 8.2.4791
Problem: Autocmd events triggered in different order when reusing an empty
buffer.
Solution: Call buff_freeall() earlier. (Charlie Groves, closes #10198)
Files: src/buffer.c, src/testdir/test_autocmd.vim


*** ../vim-8.2.4790/src/buffer.c 2022-04-10 17:59:23.339015279 +0100
--- src/buffer.c 2022-04-19 16:23:37.943580814 +0100
***************
*** 2068,2077 ****
buf = curbuf;
// It's like this buffer is deleted. Watch out for autocommands that
// change curbuf! If that happens, allocate a new buffer anyway.
! if (curbuf->b_p_bl)
! apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
! if (buf == curbuf)
! apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf);
#ifdef FEAT_EVAL
if (aborting()) // autocmds may abort script processing
{
--- 2068,2076 ----
buf = curbuf;
// It's like this buffer is deleted. Watch out for autocommands that
// change curbuf! If that happens, allocate a new buffer anyway.
! buf_freeall(buf, BFA_WIPE | BFA_DEL);
! if (buf != curbuf) // autocommands deleted the buffer!
! return NULL;
#ifdef FEAT_EVAL
if (aborting()) // autocmds may abort script processing
{
***************
*** 2079,2090 ****
return NULL;
}
#endif
- if (buf == curbuf)
- {
- // Make sure 'bufhidden' and 'buftype' are empty
- clear_string_option(&buf->b_p_bh);
- clear_string_option(&buf->b_p_bt);
- }
}
if (buf != curbuf || curbuf == NULL)
{
--- 2078,2083 ----
***************
*** 2132,2145 ****

if (buf == curbuf)
{
- // free all things allocated for this buffer
- buf_freeall(buf, 0);
- if (buf != curbuf) // autocommands deleted the buffer!
- return NULL;
- #if defined(FEAT_EVAL)
- if (aborting()) // autocmds may abort script processing
- return NULL;
- #endif
free_buffer_stuff(buf, FALSE); // delete local variables et al.

// Init the options.
--- 2125,2130 ----
*** ../vim-8.2.4790/src/testdir/test_autocmd.vim 2022-04-12 11:32:41.428327316 +0100
--- src/testdir/test_autocmd.vim 2022-04-19 16:08:27.300227840 +0100
***************
*** 3037,3045 ****
endfunc

func Test_autocmd_vimgrep()
augroup aucmd_vimgrep
! au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * sb
! au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * q9

Reply all
Reply to author
Forward
0 new messages