mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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:
18
src/buffer.c
18
src/buffer.c
@@ -450,6 +450,11 @@ close_buffer(
|
|||||||
int is_curbuf;
|
int is_curbuf;
|
||||||
int nwindows;
|
int nwindows;
|
||||||
bufref_T bufref;
|
bufref_T bufref;
|
||||||
|
# ifdef FEAT_WINDOWS
|
||||||
|
int is_curwin = (curwin!= NULL && curwin->w_buffer == buf);
|
||||||
|
win_T *the_curwin = curwin;
|
||||||
|
tabpage_T *the_curtab = curtab;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
int unload_buf = (action != 0);
|
int unload_buf = (action != 0);
|
||||||
int del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE);
|
int del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE);
|
||||||
@@ -544,6 +549,19 @@ aucmd_abort:
|
|||||||
return;
|
return;
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifdef FEAT_WINDOWS
|
||||||
|
/* 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();
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
nwindows = buf->b_nwindows;
|
nwindows = buf->b_nwindows;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -83,6 +83,16 @@ 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
|
||||||
|
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
|
||||||
|
@@ -763,6 +763,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2328,
|
||||||
/**/
|
/**/
|
||||||
2327,
|
2327,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user