diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-09-11 22:37:29 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-09-11 22:37:29 +0200 |
commit | 67f8ab829911c7901c534ef2bf19cc34b622936f (patch) | |
tree | 6d56b95950cb18a0261c0e72d685b612dbb246db /src | |
parent | 25328e39d2a6e3ded82bf282a2e248ce7209f1b4 (diff) |
patch 8.1.0369: continuation lines cannot contain commentsv8.1.0369
Problem: Continuation lines cannot contain comments.
Solution: Support using "\ .
Diffstat (limited to 'src')
-rw-r--r-- | src/ex_cmds2.c | 37 | ||||
-rw-r--r-- | src/testdir/test_eval_stuff.vim | 11 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 35 insertions, 15 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 28245d1781..c0cb87f70a 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -4864,17 +4864,21 @@ getsourceline(int c UNUSED, void *cookie, int indent UNUSED) /* 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, int indent UNUSED) 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); diff --git a/src/testdir/test_eval_stuff.vim b/src/testdir/test_eval_stuff.vim index 41ba1374d8..bcf45cc784 100644 --- a/src/testdir/test_eval_stuff.vim +++ b/src/testdir/test_eval_stuff.vim @@ -42,3 +42,14 @@ func Test_mkdir_p() call delete('Xfile') call delete('Xmkdir', 'rf') endfunc + +func Test_line_continuation() + let array = [5, + "\ ignore this + \ 6, + "\ more to ignore + "\ more moreto ignore + \ ] + "\ and some more + call assert_equal([5, 6], array) +endfunc diff --git a/src/version.c b/src/version.c index 48cd6d20bd..95fa7dae3c 100644 --- a/src/version.c +++ b/src/version.c @@ -795,6 +795,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 369, +/**/ 368, /**/ 367, |