Patch 8.2.5053
Problem:    Cannot have a comment halfway an expression in an autocmd command
            block.
Solution:   When skipping over the NL also skip over comments. (closes #10519)
Files:      src/eval.c, src/testdir/test_autocmd.vim


*** ../vim-8.2.5052/src/eval.c  2022-05-30 20:58:48.914049575 +0100
--- src/eval.c  2022-06-03 17:39:05.182196085 +0100
***************
*** 2136,2141 ****
--- 2136,2170 ----
  }
  
  /*
+  * After a NL, skip over empty lines and comment-only lines.
+  */
+     static char_u *
+ newline_skip_comments(char_u *arg)
+ {
+     char_u *p = arg + 1;
+ 
+     for (;;)
+     {
+       p = skipwhite(p);
+ 
+       if (*p == NUL)
+           break;
+       if (vim9_comment_start(p))
+       {
+           char_u *nl = vim_strchr(p, NL);
+ 
+           if (nl == NULL)
+                   break;
+           p = nl;
+       }
+       if (*p != NL)
+           break;
+       ++p;  // skip another NL
+     }
+     return p;
+ }
+ 
+ /*
   * Get the next line source line without advancing.  But do skip over comment
   * lines.
   * Only called for Vim9 script.
***************
*** 2184,2190 ****
        char_u *next;
  
        if (*p == NL)
!           next = p + 1;
        else if (evalarg->eval_cookie != NULL)
            next = getline_peek_skip_comments(evalarg);
        else
--- 2213,2219 ----
        char_u *next;
  
        if (*p == NL)
!           next = newline_skip_comments(p);
        else if (evalarg->eval_cookie != NULL)
            next = getline_peek_skip_comments(evalarg);
        else
***************
*** 2212,2218 ****
      if (arg != NULL)
      {
        if (*arg == NL)
!           return skipwhite(arg + 1);
        // Truncate before a trailing comment, so that concatenating the lines
        // won't turn the rest into a comment.
        if (*skipwhite(arg) == '#')
--- 2241,2247 ----
      if (arg != NULL)
      {
        if (*arg == NL)
!           return newline_skip_comments(arg);
        // Truncate before a trailing comment, so that concatenating the lines
        // won't turn the rest into a comment.
        if (*skipwhite(arg) == '#')
*** ../vim-8.2.5052/src/testdir/test_autocmd.vim        2022-06-01 
12:31:05.194803595 +0100
--- src/testdir/test_autocmd.vim        2022-06-03 17:37:44.914224262 +0100
***************
*** 3102,3107 ****
--- 3102,3123 ----
  
    augroup block_testing
      au!
+     autocmd CursorHold * {
+       if true
+         # comment
+         && true
+ 
+         && true
+         g:done = 'yes'
+       endif
+       }
+   augroup END
+   doautocmd CursorHold
+   call assert_equal('yes', g:done)
+ 
+   unlet g:done
+   augroup block_testing
+     au!
    augroup END
  endfunc
  
*** ../vim-8.2.5052/src/version.c       2022-06-01 21:26:30.069442412 +0100
--- src/version.c       2022-06-03 17:31:35.982333827 +0100
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     5053,
  /**/

-- 
Seen on the back of a biker's vest: If you can read this, my wife fell off.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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 on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220603164023.E372A1C12E7%40moolenaar.net.

Raspunde prin e-mail lui