[vim/vim] patch 9.2.0959: multiline dictionaries in :command and :autocmd cause E488 (PR #21073)
Amariah Abishai (Vim Github Repository) <[email protected]>
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <vim/vim/pull/[email protected]> |
Problem: A multiline dictionary argument to :command or :autocmd is parsed as a command block in Vim9 script.
Location: The issue is in the command-line collection path used by :command and :autocmd. In src/usercmd.c, may_get_cmd_block() relies on find_cmd_block_start() to determine whether subsequent lines belong to a command block. A trailing
{ in a multiline dictionary was not collected correctly, so the following dictionary entries were parsed as separate Ex commands and produced E488.
Solution: Extend the existing command-line collection logic to recognize a trailing dictionary opener when it follows an expression delimiter. Actual :command and :autocmd blocks continue to use find_cmd_block_start(), while commands such as normal! { remain ordinary command arguments and are not treated as blocks.
The fix uses the existing command-block collection path rather than introducing a separate parser or changing Vim9 expression parsing. This keeps the change localized to the existing :command and :autocmd handling and preserves the behavior added for nested command blocks.
Regression coverage was added for multiline dictionary arguments at script level and inside :def functions for both :command and :autocmd. Existing nested command-block and normal! { coverage also passes.
Tests:
- make -C src -j2
- make -C src/testdir test_usercommands.res
- make -C src/testdir test_autocmd.res
- make -C src/testdir test_vim9_script.res
- make -C src/testdir codestyle
- git diff --check
Fixes: #21070
The commit includes a Signed-off-by trailer and discloses AI assistance in the commit metadata.
You can view, comment on, or merge this pull request online at:
https://github.com/vim/vim/pull/21073
-- Commit Summary --
* patch 9.2.0959: multiline dictionaries are parsed as command blocks
-- File Changes --
M src/testdir/test_autocmd.vim (21)
M src/testdir/test_usercommands.vim (21)
M src/usercmd.c (28)
M src/version.c (2)
-- Patch Links --
https://github.com/vim/vim/pull/21073.patch
https://github.com/vim/vim/pull/21073.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/pull/21073
You are receiving this because you are subscribed to this thread.
Message ID: <vim/vim/pull/[email protected]>
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/vim/vim/pull/21073%40github.com.