diff src/ex_cmds2.c @ 14714:bdbb049c2aa8 v8.1.0369

patch 8.1.0369: continuation lines cannot contain comments commit https://github.com/vim/vim/commit/67f8ab829911c7901c534ef2bf19cc34b622936f Author: Bram Moolenaar <Bram@vim.org> Date: Tue Sep 11 22:37:29 2018 +0200 patch 8.1.0369: continuation lines cannot contain comments Problem: Continuation lines cannot contain comments. Solution: Support using "\ .
author Christian Brabandt <cb@256bit.org>
date Tue, 11 Sep 2018 22:45:07 +0200
parents 0a3b9ecf7cb8
children 27b9a84395b5
line wrap: on
line diff
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -4864,17 +4864,21 @@ getsourceline(int c UNUSED, void *cookie
 	/* compensate for the one line read-ahead */
 	--sourcing_lnum;
 
-	/* Get the next line and concatenate it when it starts with a
-	 * backslash. We always need to read the next line, keep it in
-	 * sp->nextline. */
+	// Get the next line and concatenate it when it starts with a
+	// backslash. We always need to read the next line, keep it in
+	// sp->nextline.
+	/* Also check for a comment in between continuation lines: "\ */
 	sp->nextline = get_one_sourceline(sp);
-	if (sp->nextline != NULL && *(p = skipwhite(sp->nextline)) == '\\')
+	if (sp->nextline != NULL
+		&& (*(p = skipwhite(sp->nextline)) == '\\'
+			      || (p[0] == '"' && p[1] == '\\' && p[2] == ' ')))
 	{
 	    garray_T    ga;
 
 	    ga_init2(&ga, (int)sizeof(char_u), 400);
 	    ga_concat(&ga, line);
-	    ga_concat(&ga, p + 1);
+	    if (*p == '\\')
+		ga_concat(&ga, p + 1);
 	    for (;;)
 	    {
 		vim_free(sp->nextline);
@@ -4882,18 +4886,21 @@ getsourceline(int c UNUSED, void *cookie
 		if (sp->nextline == NULL)
 		    break;
 		p = skipwhite(sp->nextline);
-		if (*p != '\\')
-		    break;
-		/* Adjust the growsize to the current length to speed up
-		 * concatenating many lines. */
-		if (ga.ga_len > 400)
+		if (*p == '\\')
 		{
-		    if (ga.ga_len > 8000)
-			ga.ga_growsize = 8000;
-		    else
-			ga.ga_growsize = ga.ga_len;
+		    // Adjust the growsize to the current length to speed up
+		    // concatenating many lines.
+		    if (ga.ga_len > 400)
+		    {
+			if (ga.ga_len > 8000)
+			    ga.ga_growsize = 8000;
+			else
+			    ga.ga_growsize = ga.ga_len;
+		    }
+		    ga_concat(&ga, p + 1);
 		}
-		ga_concat(&ga, p + 1);
+		else if (p[0] != '"' || p[1] != '\\' || p[2] != ' ')
+		    break;
 	    }
 	    ga_append(&ga, NUL);
 	    vim_free(line);