fix(autocmd): API functions accept garbage after event name #25523

"VimEnter foo" was accepted as a valid event name for "VimEnter".
Events delimited with commas, eg. "VimEnter,BufRead", were also
accepted, even though only the first event was actually parsed.

Co-authored-by: ii14 <ii14@users.noreply.github.com>
This commit is contained in:
ii14
2023-10-09 11:50:44 +02:00
committed by GitHub
parent 8e932480f6
commit 139e6f68f9
3 changed files with 23 additions and 8 deletions

View File

@@ -43,6 +43,11 @@ describe('autocmd api', function()
group = 0,
command = 'ls',
}))
eq("Invalid 'event': 'foo'", pcall_err(meths.create_autocmd, 'foo', { command = '' }))
eq("Invalid 'event': 'VimEnter '", pcall_err(meths.create_autocmd, 'VimEnter ', { command = '' }))
eq("Invalid 'event': 'VimEnter foo'", pcall_err(meths.create_autocmd, 'VimEnter foo', { command = '' }))
eq("Invalid 'event': 'BufAdd,BufDelete'", pcall_err(meths.create_autocmd, 'BufAdd,BufDelete', { command = '' }))
end)
it('doesnt leak when you use ++once', function()