mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
Merge 464473aad2
into a9031cc4a6
This commit is contained in:
commit
4d7785b335
@ -2104,12 +2104,20 @@ char *getnextac(int c, void *cookie, int indent, bool do_concat)
|
||||
|
||||
char *retval;
|
||||
if (ac->exec.type == CALLABLE_CB) {
|
||||
AutoCmd ac_copy = *ac;
|
||||
|
||||
if (oneshot) {
|
||||
ac->pat = NULL; // Assign NULL to prevent calling autocommand with once=true again
|
||||
}
|
||||
|
||||
// Can potentially reallocate kvec_t data and invalidate the ac pointer
|
||||
if (call_autocmd_callback(ac, apc)) {
|
||||
if (call_autocmd_callback(&ac_copy, apc)) {
|
||||
// If an autocommand callback returns true, delete the autocommand
|
||||
oneshot = true;
|
||||
}
|
||||
|
||||
kv_A(*acs, apc->auidx).pat = ac_copy.pat; // Restore aucmd reference
|
||||
|
||||
// TODO(tjdevries):
|
||||
//
|
||||
// Major Hack Alert:
|
||||
|
@ -250,6 +250,23 @@ describe('autocmd', function()
|
||||
--- Autocommands ---]]),
|
||||
fn.execute('autocmd Tabnew')
|
||||
)
|
||||
|
||||
--
|
||||
-- :autocmd should not recursively call ++once handlers.
|
||||
--
|
||||
exec_lua [[
|
||||
vim.g.count = 0
|
||||
vim.api.nvim_create_autocmd('User', {
|
||||
once = true,
|
||||
pattern = nil,
|
||||
callback = function()
|
||||
vim.g.count = vim.g.count + 1
|
||||
vim.api.nvim_exec_autocmds('User', { pattern = nil })
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_exec_autocmds('User', { pattern = nil })
|
||||
]]
|
||||
eq(1, eval('g:count')) -- Added autocommands should not be executed
|
||||
end)
|
||||
|
||||
it('internal `aucmd_win` window', function()
|
||||
|
Loading…
Reference in New Issue
Block a user