diff src/userfunc.c @ 20023:c85d4e173cc9 v8.2.0567

patch 8.2.0567: Vim9: cannot put comments halfway expressions Commit: https://github.com/vim/vim/commit/2c330432cfb12181c61d698b5459bfd73d2610df Author: Bram Moolenaar <Bram@vim.org> Date: Mon Apr 13 14:41:35 2020 +0200 patch 8.2.0567: Vim9: cannot put comments halfway expressions Problem: Vim9: cannot put comments halfway expressions. Solution: Support # comments in many places.
author Bram Moolenaar <Bram@vim.org>
date Mon, 13 Apr 2020 14:45:04 +0200
parents c001ee73519a
children 8fb1cf4c44d5
line wrap: on
line diff
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -154,6 +154,7 @@ get_function_args(
     int		c;
     int		any_default = FALSE;
     char_u	*expr;
+    char_u	*whitep = arg;
 
     if (newargs != NULL)
 	ga_init2(newargs, (int)sizeof(char_u *), 3);
@@ -170,7 +171,8 @@ get_function_args(
      */
     while (*p != endchar)
     {
-	if (eap != NULL && *p == NUL && eap->getline != NULL)
+	while (eap != NULL && eap->getline != NULL
+			 && (*p == NUL || (VIM_ISWHITE(*whitep) && *p == '#')))
 	{
 	    char_u *theline;
 
@@ -180,6 +182,7 @@ get_function_args(
 		break;
 	    vim_free(*line_to_free);
 	    *line_to_free = theline;
+	    whitep = (char_u *)" ";
 	    p = skipwhite(theline);
 	}
 
@@ -228,6 +231,7 @@ get_function_args(
 		// find the end of the expression (doesn't evaluate it)
 		any_default = TRUE;
 		p = skipwhite(p) + 1;
+		whitep = p;
 		p = skipwhite(p);
 		expr = p;
 		if (eval1(&p, &rettv, FALSE) != FAIL)
@@ -264,6 +268,7 @@ get_function_args(
 	    else
 		mustend = TRUE;
 	}
+	whitep = p;
 	p = skipwhite(p);
     }
 
@@ -2595,7 +2600,8 @@ ex_function(exarg_T *eap)
     // Makes 'exe "func Test()\n...\nendfunc"' work.
     if (*p == '\n')
 	line_arg = p + 1;
-    else if (*p != NUL && *p != '"' && !eap->skip && !did_emsg)
+    else if (*p != NUL && *p != '"' && !(eap->cmdidx == CMD_def && *p == '#')
+						    && !eap->skip && !did_emsg)
 	emsg(_(e_trailing));
 
     /*