]> granicus.if.org Git - vim/commitdiff
patch 8.2.3405: cannot have a comment line in a {} block of a user command v8.2.3405
authorBram Moolenaar <Bram@vim.org>
Mon, 6 Sep 2021 15:10:59 +0000 (17:10 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 6 Sep 2021 15:10:59 +0000 (17:10 +0200)
Problem:    Cannot have a comment line in a {} block of a user command.
Solution:   Continue after the line break. (closes #8837)

src/ex_docmd.c
src/testdir/test_usercommands.vim
src/version.c

index 58980738f27c6e091dfeddd523541a056fd5f0bb..c58c414108a45edcbce80256e580a4aaf31dc42f 100644 (file)
@@ -2807,7 +2807,16 @@ parse_command_modifiers(
 
        // ignore comment and empty lines
        if (comment_start(eap->cmd, starts_with_colon))
+       {
+           // a comment ends at a NL
+           if (eap->nextcmd == NULL)
+           {
+               eap->nextcmd = vim_strchr(eap->cmd, '\n');
+               if (eap->nextcmd != NULL)
+                   ++eap->nextcmd;
+           }
            return FAIL;
+       }
        if (*eap->cmd == NUL)
        {
            if (!skip_only)
index 9cb592e23018dfd6dae0ae55a5fd3e2ae0e63143..3f15dc187d1e723851a47a42e1572530235ee372 100644 (file)
@@ -624,7 +624,8 @@ endfunc
 
 func Test_usercmd_with_block()
   command DoSomething {
-        g:didit = 'yes'
+        g:didit = 'yes'  # comment
+        # comment line
         g:didmore = 'more'
       }
   DoSomething
index cfddf6bad62b8f089f72f7ba63671ec5b87187bc..742f89915b312a2450c29b52328c2f9a07fc32ee 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3405,
 /**/
     3404,
 /**/