mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.4.2328
Problem: Crash when BufWinLeave autocmd goes to another tab page. (Hirohito Higashi) Solution: Make close_buffer() go back to the right window.
This commit is contained in:
parent
4a2e6f460d
commit
10f6624f65
@ -337,6 +337,10 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last)
|
|||||||
bool del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE);
|
bool del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE);
|
||||||
bool wipe_buf = (action == DOBUF_WIPE);
|
bool wipe_buf = (action == DOBUF_WIPE);
|
||||||
|
|
||||||
|
bool is_curwin = (curwin != NULL && curwin->w_buffer == buf);
|
||||||
|
win_T *the_curwin = curwin;
|
||||||
|
tabpage_T *the_curtab = curtab;
|
||||||
|
|
||||||
// Force unloading or deleting when 'bufhidden' says so, but not for terminal
|
// Force unloading or deleting when 'bufhidden' says so, but not for terminal
|
||||||
// buffers.
|
// buffers.
|
||||||
// The caller must take care of NOT deleting/freeing when 'bufhidden' is
|
// The caller must take care of NOT deleting/freeing when 'bufhidden' is
|
||||||
@ -419,6 +423,16 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last)
|
|||||||
if (aborting()) /* autocmds may abort script processing */
|
if (aborting()) /* autocmds may abort script processing */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the buffer was in curwin and the window has changed, go back to that
|
||||||
|
// window, if it still exists. This avoids that ":edit x" triggering a
|
||||||
|
// "tabnext" BufUnload autocmd leaves a window behind without a buffer.
|
||||||
|
if (is_curwin && curwin != the_curwin && win_valid_any_tab(the_curwin)) {
|
||||||
|
block_autocmds();
|
||||||
|
goto_tabpage_win(the_curtab, the_curwin);
|
||||||
|
unblock_autocmds();
|
||||||
|
}
|
||||||
|
|
||||||
int nwindows = buf->b_nwindows;
|
int nwindows = buf->b_nwindows;
|
||||||
|
|
||||||
/* decrease the link count from windows (unless not in any window) */
|
/* decrease the link count from windows (unless not in any window) */
|
||||||
|
@ -98,6 +98,17 @@ function Test_autocmd_bufunload_with_tabnext()
|
|||||||
quit
|
quit
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
function Test_autocmd_bufwinleave_with_tabfirst()
|
||||||
|
tabedit
|
||||||
|
augroup sample
|
||||||
|
autocmd!
|
||||||
|
autocmd BufWinLeave <buffer> tabfirst
|
||||||
|
augroup END
|
||||||
|
call setline(1, ['a', 'b', 'c'])
|
||||||
|
edit! a.txt
|
||||||
|
tabclose
|
||||||
|
endfunc
|
||||||
|
|
||||||
" SEGV occurs in older versions. (At least 7.4.2321 or older)
|
" SEGV occurs in older versions. (At least 7.4.2321 or older)
|
||||||
function Test_autocmd_bufunload_avoiding_SEGV_01()
|
function Test_autocmd_bufunload_avoiding_SEGV_01()
|
||||||
split aa.txt
|
split aa.txt
|
||||||
|
@ -113,7 +113,7 @@ static int included_patches[] = {
|
|||||||
2331,
|
2331,
|
||||||
// 2330,
|
// 2330,
|
||||||
2329,
|
2329,
|
||||||
// 2328,
|
2328,
|
||||||
// 2327 NA
|
// 2327 NA
|
||||||
2326,
|
2326,
|
||||||
// 2325 NA
|
// 2325 NA
|
||||||
|
Loading…
Reference in New Issue
Block a user