patch 8.2.1934: Vim9: command modifiers in :def function not tested
Problem: Vim9: command modifiers in :def function not tested.
Solution: Add tests. Fix using modifier before filter command.
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 48da263..d2cc05f 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1782,14 +1782,27 @@
*/
cmd = ea.cmd;
#ifdef FEAT_EVAL
- // In Vim9 script a colon is required before the range.
- may_have_range = !vim9script || starts_with_colon;
+ // In Vim9 script a colon is required before the range. This may also be
+ // after command modifiers.
+ if (vim9script)
+ {
+ may_have_range = FALSE;
+ for (p = ea.cmd; p >= *cmdlinep; --p)
+ {
+ if (*p == ':')
+ may_have_range = TRUE;
+ if (p < ea.cmd && !VIM_ISWHITE(*p))
+ break;
+ }
+ }
+ else
+ may_have_range = TRUE;
if (may_have_range)
#endif
ea.cmd = skip_range(ea.cmd, TRUE, NULL);
#ifdef FEAT_EVAL
- if (vim9script && !starts_with_colon)
+ if (vim9script && !may_have_range)
{
if (ea.cmd == cmd + 1 && *cmd == '$')
// should be "$VAR = val"