mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.4.1837 (#5834)
Problem: The BufUnload event is triggered twice, when :bunload is used with
set to or .
Solution: Do not trigger the event when ml_mfp is NULL. (Hirohito Higashi)
c67e892134
This commit is contained in:
parent
9066e23562
commit
1928b79e0c
@ -509,9 +509,12 @@ void buf_freeall(buf_T *buf, int flags)
|
|||||||
|
|
||||||
// Make sure the buffer isn't closed by autocommands.
|
// Make sure the buffer isn't closed by autocommands.
|
||||||
buf->b_closing = true;
|
buf->b_closing = true;
|
||||||
apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, FALSE, buf);
|
if (buf->b_ml.ml_mfp != NULL) {
|
||||||
if (!buf_valid(buf)) /* autocommands may delete the buffer */
|
apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, false, buf);
|
||||||
return;
|
if (!buf_valid(buf)) { // autocommands may delete the buffer
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if ((flags & BFA_DEL) && buf->b_p_bl) {
|
if ((flags & BFA_DEL) && buf->b_p_bl) {
|
||||||
apply_autocmds(EVENT_BUFDELETE, buf->b_fname, buf->b_fname, FALSE, buf);
|
apply_autocmds(EVENT_BUFDELETE, buf->b_fname, buf->b_fname, FALSE, buf);
|
||||||
if (!buf_valid(buf)) /* autocommands may delete the buffer */
|
if (!buf_valid(buf)) /* autocommands may delete the buffer */
|
||||||
|
@ -7,29 +7,56 @@ func Test_vim_did_enter()
|
|||||||
" becomes one.
|
" becomes one.
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
if !has('timers')
|
if has('timers')
|
||||||
finish
|
func ExitInsertMode(id)
|
||||||
|
call feedkeys("\<Esc>")
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_cursorhold_insert()
|
||||||
|
let g:triggered = 0
|
||||||
|
au CursorHoldI * let g:triggered += 1
|
||||||
|
set updatetime=20
|
||||||
|
call timer_start(100, 'ExitInsertMode')
|
||||||
|
call feedkeys('a', 'x!')
|
||||||
|
call assert_equal(1, g:triggered)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_cursorhold_insert_ctrl_x()
|
||||||
|
let g:triggered = 0
|
||||||
|
au CursorHoldI * let g:triggered += 1
|
||||||
|
set updatetime=20
|
||||||
|
call timer_start(100, 'ExitInsertMode')
|
||||||
|
" CursorHoldI does not trigger after CTRL-X
|
||||||
|
call feedkeys("a\<C-X>", 'x!')
|
||||||
|
call assert_equal(0, g:triggered)
|
||||||
|
endfunc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
func ExitInsertMode(id)
|
function Test_bufunload()
|
||||||
call feedkeys("\<Esc>")
|
augroup test_bufunload_group
|
||||||
endfunc
|
autocmd!
|
||||||
|
autocmd BufUnload * call add(s:li, "bufunload")
|
||||||
|
autocmd BufDelete * call add(s:li, "bufdelete")
|
||||||
|
autocmd BufWipeout * call add(s:li, "bufwipeout")
|
||||||
|
augroup END
|
||||||
|
|
||||||
func Test_cursorhold_insert()
|
let s:li=[]
|
||||||
let g:triggered = 0
|
new
|
||||||
au CursorHoldI * let g:triggered += 1
|
setlocal bufhidden=
|
||||||
set updatetime=20
|
bunload
|
||||||
call timer_start(100, 'ExitInsertMode')
|
call assert_equal(["bufunload", "bufdelete"], s:li)
|
||||||
call feedkeys('a', 'x!')
|
|
||||||
call assert_equal(1, g:triggered)
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_cursorhold_insert_ctrl_x()
|
let s:li=[]
|
||||||
let g:triggered = 0
|
new
|
||||||
au CursorHoldI * let g:triggered += 1
|
setlocal bufhidden=delete
|
||||||
set updatetime=20
|
bunload
|
||||||
call timer_start(100, 'ExitInsertMode')
|
call assert_equal(["bufunload", "bufdelete"], s:li)
|
||||||
" CursorHoldI does not trigger after CTRL-X
|
|
||||||
call feedkeys("a\<C-X>", 'x!')
|
let s:li=[]
|
||||||
call assert_equal(0, g:triggered)
|
new
|
||||||
|
setlocal bufhidden=unload
|
||||||
|
bwipeout
|
||||||
|
call assert_equal(["bufunload", "bufdelete", "bufwipeout"], s:li)
|
||||||
|
|
||||||
|
augroup! test_bufunload_group
|
||||||
endfunc
|
endfunc
|
||||||
|
@ -603,7 +603,7 @@ static int included_patches[] = {
|
|||||||
1840,
|
1840,
|
||||||
// 1839,
|
// 1839,
|
||||||
// 1838,
|
// 1838,
|
||||||
// 1837,
|
1837,
|
||||||
1836,
|
1836,
|
||||||
1835,
|
1835,
|
||||||
1833,
|
1833,
|
||||||
|
Loading…
Reference in New Issue
Block a user