fix(autocmd): api functions accepting garbage after event name

"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.

(cherry picked from commit 1397016259)
This commit is contained in:
ii14
2023-10-06 14:34:22 +02:00
committed by Christian Clason
parent 2bde3109b8
commit eddead1cad
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()