aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c21
-rw-r--r--src/nvim/testdir/test_autocmd.vim23
2 files changed, 24 insertions, 20 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 628e398fd4..30bd37fe7f 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -1748,21 +1748,14 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int fl
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);
+ buf_freeall(buf, BFA_WIPE | BFA_DEL);
+ if (buf != curbuf) { // autocommands deleted the buffer!
+ return NULL;
}
if (aborting()) { // autocmds may abort script processing
xfree(ffname);
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) {
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));
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.
// Init the options.
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim
index 12b6ab26bc..5913032195 100644
--- a/src/nvim/testdir/test_autocmd.vim
+++ b/src/nvim/testdir/test_autocmd.vim
@@ -2748,9 +2748,10 @@ func Test_autocmd_closing_cmdwin()
endfunc
func Test_autocmd_vimgrep()
+ %bwipe!
augroup aucmd_vimgrep
- au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * sb
- au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * q9
+ au QuickfixCmdPre,BufNew,BufReadCmd * sb
+ au QuickfixCmdPre,BufNew,BufReadCmd * q9
augroup END
%bwipe!
call assert_fails('lv ?a? foo', 'E926:')
@@ -2795,4 +2796,22 @@ func Test_v_event_readonly()
endfunc
+func Test_noname_autocmd()
+ augroup test_noname_autocmd_group
+ autocmd!
+ autocmd BufEnter * call add(s:li, ["BufEnter", expand("<afile>")])
+ autocmd BufDelete * call add(s:li, ["BufDelete", expand("<afile>")])
+ autocmd BufLeave * call add(s:li, ["BufLeave", expand("<afile>")])
+ autocmd BufUnload * call add(s:li, ["BufUnload", expand("<afile>")])
+ autocmd BufWipeout * call add(s:li, ["BufWipeout", expand("<afile>")])
+ augroup END
+
+ let s:li = []
+ edit foo
+ call assert_equal([['BufUnload', ''], ['BufDelete', ''], ['BufWipeout', ''], ['BufEnter', 'foo']], s:li)
+
+ au! test_noname_autocmd_group
+ augroup! test_noname_autocmd_group
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab