mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 14:58:18 +00:00
autocmd: WinClosed exposes window id as <afile>
This commit is contained in:
@@ -6862,7 +6862,8 @@ static bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io,
|
|||||||
|| event == EVENT_SPELLFILEMISSING
|
|| event == EVENT_SPELLFILEMISSING
|
||||||
|| event == EVENT_SYNTAX
|
|| event == EVENT_SYNTAX
|
||||||
|| event == EVENT_SIGNAL
|
|| event == EVENT_SIGNAL
|
||||||
|| event == EVENT_TABCLOSED) {
|
|| event == EVENT_TABCLOSED
|
||||||
|
|| event == EVENT_WINCLOSED) {
|
||||||
fname = vim_strsave(fname);
|
fname = vim_strsave(fname);
|
||||||
} else {
|
} else {
|
||||||
fname = (char_u *)FullName_save((char *)fname, false);
|
fname = (char_u *)FullName_save((char *)fname, false);
|
||||||
|
@@ -2695,8 +2695,10 @@ static void do_autocmd_winclosed(win_T *win)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
recursive = true;
|
recursive = true;
|
||||||
apply_autocmds(EVENT_WINCLOSED, win->w_buffer->b_fname,
|
|
||||||
win->w_buffer->b_fname, false, win->w_buffer);
|
char_u winid[10];
|
||||||
|
vim_snprintf((char *)winid, sizeof(winid), "%i", win->handle);
|
||||||
|
apply_autocmds(EVENT_WINCLOSED, winid, winid, false, win->w_buffer);
|
||||||
recursive = false;
|
recursive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,6 +50,13 @@ describe('autocmd', function()
|
|||||||
eq(1, eval('g:triggered'))
|
eq(1, eval('g:triggered'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('WinClosed event exposes window id as <afile>', function()
|
||||||
|
command('new')
|
||||||
|
local id = meths.get_current_win().id
|
||||||
|
helpers.nvim('command', 'au! WinClosed * echom "winclosed:".expand("<afile>").":".expand("<amatch>").":".win_getid()')
|
||||||
|
eq(string.format("winclosed:%s:%s:%s", id, id, id), helpers.nvim('exec', 'close', true))
|
||||||
|
end)
|
||||||
|
|
||||||
it(':bdelete triggers WinClosed event', function()
|
it(':bdelete triggers WinClosed event', function()
|
||||||
command('let g:triggered = 0')
|
command('let g:triggered = 0')
|
||||||
command('autocmd WinClosed <buffer> :let g:triggered+=1')
|
command('autocmd WinClosed <buffer> :let g:triggered+=1')
|
||||||
|
Reference in New Issue
Block a user