mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
vim-patch:8.2.4791: events triggered in different order when reusing buffer
Problem: Autocmd events triggered in different order when reusing an empty
buffer.
Solution: Call buff_freeall() earlier. (Charlie Groves, closes vim/vim#10198)
fef4485ef5
Test failure becomes very strange.
This commit is contained in:
@@ -1748,21 +1748,14 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int fl
|
|||||||
buf = curbuf;
|
buf = curbuf;
|
||||||
// It's like this buffer is deleted. Watch out for autocommands that
|
// It's like this buffer is deleted. Watch out for autocommands that
|
||||||
// change curbuf! If that happens, allocate a new buffer anyway.
|
// change curbuf! If that happens, allocate a new buffer anyway.
|
||||||
if (curbuf->b_p_bl) {
|
buf_freeall(buf, BFA_WIPE | BFA_DEL);
|
||||||
apply_autocmds(EVENT_BUFDELETE, NULL, NULL, false, curbuf);
|
if (buf != curbuf) { // autocommands deleted the buffer!
|
||||||
}
|
return NULL;
|
||||||
if (buf == curbuf) {
|
|
||||||
apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, false, curbuf);
|
|
||||||
}
|
}
|
||||||
if (aborting()) { // autocmds may abort script processing
|
if (aborting()) { // autocmds may abort script processing
|
||||||
xfree(ffname);
|
xfree(ffname);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
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) {
|
if (buf != curbuf || curbuf == NULL) {
|
||||||
buf = xcalloc(1, sizeof(buf_T));
|
buf = xcalloc(1, sizeof(buf_T));
|
||||||
@@ -1782,14 +1775,6 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int fl
|
|||||||
buf->b_wininfo = xcalloc(1, sizeof(wininfo_T));
|
buf->b_wininfo = xcalloc(1, sizeof(wininfo_T));
|
||||||
|
|
||||||
if (buf == curbuf) {
|
if (buf == curbuf) {
|
||||||
// free all things allocated for this buffer
|
|
||||||
buf_freeall(buf, 0);
|
|
||||||
if (buf != curbuf) { // autocommands deleted the buffer!
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (aborting()) { // autocmds may abort script processing
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
free_buffer_stuff(buf, kBffInitChangedtick); // delete local vars et al.
|
free_buffer_stuff(buf, kBffInitChangedtick); // delete local vars et al.
|
||||||
|
|
||||||
// Init the options.
|
// Init the options.
|
||||||
|
@@ -2748,9 +2748,10 @@ func Test_autocmd_closing_cmdwin()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_autocmd_vimgrep()
|
func Test_autocmd_vimgrep()
|
||||||
|
%bwipe!
|
||||||
augroup aucmd_vimgrep
|
augroup aucmd_vimgrep
|
||||||
au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * sb
|
au QuickfixCmdPre,BufNew,BufReadCmd * sb
|
||||||
au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * q9 |