aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-04-20 11:11:39 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-04-21 19:07:50 +0800
commitf531fb97ff5009d2ac279a83da9b9e911c350c89 (patch)
tree4a6c501c53e95ebcbca98373654879942869de46 /src/nvim/buffer.c
parent69fc23ed9819f2640106ce38613ed6f0962ae926 (diff)
downloadrneovim-f531fb97ff5009d2ac279a83da9b9e911c350c89.tar.gz
rneovim-f531fb97ff5009d2ac279a83da9b9e911c350c89.tar.bz2
rneovim-f531fb97ff5009d2ac279a83da9b9e911c350c89.zip
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) https://github.com/vim/vim/commit/fef4485ef58d5937b170c6dc69431359469fc9cd Test failure becomes very strange.
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c21
1 files changed, 3 insertions, 18 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.