mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Problem: Setting 'term' may cause error in TermChanged autocommand. Solution: Use aucmd_prepbuf() to switch to the buffer where the autocommand is to be executed. (closes #5682)
This commit is contained in:
parent
b654103ad1
commit
0c81d1b112
13
src/term.c
13
src/term.c
@ -2071,21 +2071,24 @@ set_termname(char_u *term)
|
|||||||
check_map_keycodes(); // check mappings for terminal codes used
|
check_map_keycodes(); // check mappings for terminal codes used
|
||||||
|
|
||||||
{
|
{
|
||||||
bufref_T old_curbuf;
|
buf_T *buf;
|
||||||
|
aco_save_T aco;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Execute the TermChanged autocommands for each buffer that is
|
* Execute the TermChanged autocommands for each buffer that is
|
||||||
* loaded.
|
* loaded.
|
||||||
*/
|
*/
|
||||||
set_bufref(&old_curbuf, curbuf);
|
FOR_ALL_BUFFERS(buf)
|
||||||
FOR_ALL_BUFFERS(curbuf)
|
|
||||||
{
|
{
|
||||||
if (curbuf->b_ml.ml_mfp != NULL)
|
if (curbuf->b_ml.ml_mfp != NULL)
|
||||||
|
{
|
||||||
|
aucmd_prepbuf(&aco, buf);
|
||||||
apply_autocmds(EVENT_TERMCHANGED, NULL, NULL, FALSE,
|
apply_autocmds(EVENT_TERMCHANGED, NULL, NULL, FALSE,
|
||||||
curbuf);
|
curbuf);
|
||||||
|
// restore curwin/curbuf and a few other things
|
||||||
|
aucmd_restbuf(&aco);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (bufref_valid(&old_curbuf))
|
|
||||||
curbuf = old_curbuf.br_buf;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2382,4 +2382,24 @@ func Test_FileChangedRO_winclose()
|
|||||||
augroup! FileChangedROTest
|
augroup! FileChangedROTest
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func LogACmd()
|
||||||
|
call add(g:logged, line('$'))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_TermChanged()
|
||||||
|
enew!
|
||||||
|
tabnew
|
||||||
|
call setline(1, ['a', 'b', 'c', 'd'])
|
||||||
|
$
|
||||||
|
au TermChanged * call LogACmd()
|
||||||
|
let g:logged = []
|
||||||
|
let term_save = &term
|
||||||
|
set term=xterm
|
||||||
|
call assert_equal([1, 4], g:logged)
|
||||||
|
|
||||||
|
au! TermChanged
|
||||||
|
let &term = term_save
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -738,6 +738,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 */
|
||||||
|
/**/
|
||||||
|
302,
|
||||||
/**/
|
/**/
|
||||||
301,
|
301,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user