aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-06-23 22:46:02 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-06-23 23:16:20 -0400
commitcd4b649136b9c4529a6f2f9043ad0c7335126d71 (patch)
tree64c562815ab6c9e90b57ae78df3850bcd5a2c73e /src
parent4cb0bf09421e88adb812bb716b56af22bd51353e (diff)
downloadrneovim-cd4b649136b9c4529a6f2f9043ad0c7335126d71.tar.gz
rneovim-cd4b649136b9c4529a6f2f9043ad0c7335126d71.tar.bz2
rneovim-cd4b649136b9c4529a6f2f9043ad0c7335126d71.zip
vim-patch:8.2.2185: BufUnload is not triggered for the quickfix dummy buffer
Problem: BufUnload is not triggered for the quickfix dummy buffer. Solution: Do trigger BufUnload. (Pontus Leitzler,closes vim/vim#7518, closes vim/vim#7517) Fix white space around "=". https://github.com/vim/vim/commit/1cfb9bb5c06c07f14475f39c4eb57fea1f0dfb69
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c2
-rw-r--r--src/nvim/ex_cmds.c5
-rw-r--r--src/nvim/quickfix.c2
-rw-r--r--src/nvim/testdir/test_autocmd.vim75
4 files changed, 54 insertions, 30 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 6a50264e0f..0b72dd1885 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -5665,7 +5665,7 @@ bool buf_contents_changed(buf_T *buf)
void
wipe_buffer(
buf_T *buf,
- int aucmd // When true trigger autocommands.
+ bool aucmd // When true trigger autocommands.
)
{
if (!aucmd) {
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 6a0a08eee8..23383abc57 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -4773,8 +4773,9 @@ void ex_help(exarg_T *eap)
* window. */
if (empty_fnum != 0 && curbuf->b_fnum != empty_fnum) {
buf = buflist_findnr(empty_fnum);
- if (buf != NULL && buf->b_nwindows == 0)
- wipe_buffer(buf, TRUE);
+ if (buf != NULL && buf->b_nwindows == 0) {
+ wipe_buffer(buf, true);
+ }
}
/* keep the previous alternate file */
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 508257d5b1..3e8d623ed4 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -5713,7 +5713,7 @@ static void wipe_dummy_buffer(buf_T *buf, char_u *dirname_start)
// work when got_int is set.
enter_cleanup(&cs);
- wipe_buffer(buf, FALSE);
+ wipe_buffer(buf, true);
// Restore the error/interrupt/exception state if not discarded by a
// new aborting error, interrupt, or uncaught exception.
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim
index bb84fa498e..ad28118f16 100644
--- a/src/nvim/testdir/test_autocmd.vim
+++ b/src/nvim/testdir/test_autocmd.vim
@@ -108,19 +108,19 @@ func Test_bufunload()
autocmd BufWipeout * call add(s:li, "bufwipeout")
augroup END
- let s:li=[]
+ let s:li = []
new
setlocal bufhidden=
bunload
call assert_equal(["bufunload", "bufdelete"], s:li)
- let s:li=[]
+ let s:li = []
new
setlocal bufhidden=delete
bunload
call assert_equal(["bufunload", "bufdelete"], s:li)
- let s:li=[]
+ let s:li = []
new
setlocal bufhidden=unload
bwipeout
@@ -196,6 +196,29 @@ func Test_autocmd_bufunload_avoiding_SEGV_02()
bwipe! a.txt
endfunc
+func Test_autocmd_dummy_wipeout()
+ " prepare files
+ call writefile([''], 'Xdummywipetest1.txt')
+ call writefile([''], 'Xdummywipetest2.txt')
+ augroup test_bufunload_group
+ autocmd!
+ autocmd BufUnload * call add(s:li, "bufunload")
+ autocmd BufDelete * call add(s:li, "bufdelete")
+ autocmd BufWipeout * call add(s:li, "bufwipeout")
+ augroup END
+
+ let s:li = []
+ split Xdummywipetest1.txt
+ silent! vimgrep /notmatched/ Xdummywipetest*
+ call assert_equal(["bufunload", "bufwipeout"], s:li)
+
+ bwipeout
+ call delete('Xdummywipetest1.txt')
+ call delete('Xdummywipetest2.txt')
+ au! test_bufunload_group
+ augroup! test_bufunload_group
+endfunc
+
func Test_win_tab_autocmd()
let g:record = []
@@ -428,7 +451,7 @@ func Test_autocmd_bufwipe_in_SessLoadPost()
let content =<< trim [CODE]
set nocp noswapfile
- let v:swapchoice="e"
+ let v:swapchoice = "e"
augroup test_autocmd_sessionload
autocmd!
autocmd SessionLoadPost * exe bufnr("Xsomething") . "bw!"
@@ -537,92 +560,92 @@ func Test_OptionSet()
au OptionSet * :call s:AutoCommandOptionSet(expand("<amatch>"))
" 1: Setting number option"
- let g:options=[['number', 0, 1, 'global']]
+ let g:options = [['number', 0, 1, 'global']]
set nu
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 2: Setting local number option"
- let g:options=[['number', 1, 0, 'local']]
+ let g:options = [['number', 1, 0, 'local']]
setlocal nonu
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 3: Setting global number option"
- let g:options=[['number', 1, 0, 'global']]
+ let g:options = [['number', 1, 0, 'global']]
setglobal nonu
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 4: Setting local autoindent option"
- let g:options=[['autoindent', 0, 1, 'local']]
+ let g:options = [['autoindent', 0, 1, 'local']]
setlocal ai
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 5: Setting global autoindent option"
- let g:options=[['autoindent', 0, 1, 'global']]
+ let g:options = [['autoindent', 0, 1, 'global']]
setglobal ai
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 6: Setting global autoindent option"
- let g:options=[['autoindent', 1, 0, 'global']]
+ let g:options = [['autoindent', 1, 0, 'global']]
set ai!
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" Should not print anything, use :noa
" 7: don't trigger OptionSet"
- let g:options=[['invalid', 1, 1, 'invalid']]
+ let g:options = [['invalid', 1, 1, 'invalid']]
noa set nonu
call assert_equal([['invalid', 1, 1, 'invalid']], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 8: Setting several global list and number option"
- let g:options=[['list', 0, 1, 'global'], ['number', 0, 1, 'global']]
+ let g:options = [['list', 0, 1, 'global'], ['number', 0, 1, 'global']]
set list nu
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 9: don't trigger OptionSet"
- let g:options=[['invalid', 1, 1, 'invalid'], ['invalid', 1, 1, 'invalid']]
+ let g:options = [['invalid', 1, 1, 'invalid'], ['invalid', 1, 1, 'invalid']]
noa set nolist nonu
call assert_equal([['invalid', 1, 1, 'invalid'], ['invalid', 1, 1, 'invalid']], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 10: Setting global acd"
- let g:options=[['autochdir', 0, 1, 'local']]
+ let g:options = [['autochdir', 0, 1, 'local']]
setlocal acd
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 11: Setting global autoread (also sets local value)"
- let g:options=[['autoread', 0, 1, 'global']]
+ let g:options = [['autoread', 0, 1, 'global']]
set ar
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 12: Setting local autoread"
- let g:options=[['autoread', 1, 1, 'local']]
+ let g:options = [['autoread', 1, 1, 'local']]
setlocal ar
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 13: Setting global autoread"
- let g:options=[['autoread', 1, 0, 'global']]
+ let g:options = [['autoread', 1, 0, 'global']]
setglobal invar
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 14: Setting option backspace through :let"
- let g:options=[['backspace', '', 'eol,indent,start', 'global']]
- let &bs="eol,indent,start"
+ let g:options = [['backspace', '', 'eol,indent,start', 'global']]
+ let &bs = "eol,indent,start"
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 15: Setting option backspace through setbufvar()"
- let g:options=[['backup', 0, 1, 'local']]
+ let g:options = [['backup', 0, 1, 'local']]
" try twice, first time, shouldn't trigger because option name is invalid,
" second time, it should trigger
call assert_fails("call setbufvar(1, '&l:bk', 1)", "E355")
@@ -632,13 +655,13 @@ func Test_OptionSet()
call assert_equal(g:opt[0], g:opt[1])
" 16: Setting number option using setwinvar"
- let g:options=[['number', 0, 1, 'local']]
+ let g:options = [['number', 0, 1, 'local']]
call setwinvar(0, '&number', 1)
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 17: Setting key option, shouldn't trigger"
- let g:options=[['key', 'invalid', 'invalid1', 'invalid']]
+ let g:options = [['key', 'invalid', 'invalid1', 'invalid']]
setlocal key=blah
setlocal key=
call assert_equal([['key', 'invalid', 'invalid1', 'invalid']], g:options)
@@ -646,13 +669,13 @@ func Test_OptionSet()
" 18: Setting string option"
let oldval = &tags
- let g:options=[['tags', oldval, 'tagpath', 'global']]
+ let g:options = [['tags', oldval, 'tagpath', 'global']]
set tags=tagpath
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
" 1l: Resetting string option"
- let g:options=[['tags', 'tagpath', oldval, 'global']]
+ let g:options = [['tags', 'tagpath', oldval, 'global']]
set tags&
call assert_equal([], g:options)
call assert_equal(g:opt[0], g:opt[1])
@@ -672,7 +695,7 @@ func Test_OptionSet_diffmode()
call test_override('starting', 1)
" 18: Changing an option when entering diff mode
new
- au OptionSet diff :let &l:cul=v:option_new
+ au OptionSet diff :let &l:cul = v:option_new
call setline(1, ['buffer 1', 'line2', 'line3', 'line4'])
call assert_equal(0, &l:cul)
@@ -1754,7 +1777,7 @@ func Test_autocmd_CmdWinEnter()
autocmd CmdWinEnter * quit
let winnr = winnr('$')
END
- let filename='XCmdWinEnter'
+ let filename = 'XCmdWinEnter'
call writefile(lines, filename)
let buf = RunVimInTerminal('-S '.filename, #{rows: 6})