Mirror of the Vim source from https://github.com/vim/vim
Révision | b3124656f050c31293b3dbd4a97235c019dfb50f (tree) |
---|---|
l'heure | 2020-12-02 21:30:04 |
Auteur | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
patch 8.2.2079: Vim9: cannot put a linebreak before or after "in" of ":for"
Commit: https://github.com/vim/vim/commit/38bd8de551225bfca133805f21cee2592f0c759d
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Dec 2 13:23:36 2020 +0100
@@ -1849,6 +1849,28 @@ | ||
1849 | 1849 | concat ..= str |
1850 | 1850 | endfor |
1851 | 1851 | assert_equal('onetwo', concat) |
1852 | + | |
1853 | + var total = 0 | |
1854 | + for nr in | |
1855 | + [1, 2, 3] | |
1856 | + total += nr | |
1857 | + endfor | |
1858 | + assert_equal(6, total) | |
1859 | + | |
1860 | + total = 0 | |
1861 | + for nr | |
1862 | + in [1, 2, 3] | |
1863 | + total += nr | |
1864 | + endfor | |
1865 | + assert_equal(6, total) | |
1866 | + | |
1867 | + total = 0 | |
1868 | + for nr | |
1869 | + in | |
1870 | + [1, 2, 3] | |
1871 | + total += nr | |
1872 | + endfor | |
1873 | + assert_equal(6, total) | |
1852 | 1874 | enddef |
1853 | 1875 | |
1854 | 1876 | def Test_for_loop_fails() |
@@ -751,6 +751,8 @@ | ||
751 | 751 | static int included_patches[] = |
752 | 752 | { /* Add new patch number below this line */ |
753 | 753 | /**/ |
754 | + 2079, | |
755 | +/**/ | |
754 | 756 | 2078, |
755 | 757 | /**/ |
756 | 758 | 2077, |
@@ -6486,6 +6486,7 @@ | ||
6486 | 6486 | char_u *arg_end; |
6487 | 6487 | char_u *name = NULL; |
6488 | 6488 | char_u *p; |
6489 | + char_u *wp; | |
6489 | 6490 | int var_count = 0; |
6490 | 6491 | int semicolon = FALSE; |
6491 | 6492 | size_t varlen; |
@@ -6503,13 +6504,19 @@ | ||
6503 | 6504 | var_count = 1; |
6504 | 6505 | |
6505 | 6506 | // consume "in" |
6507 | + wp = p; | |
6506 | 6508 | p = skipwhite(p); |
6507 | - if (STRNCMP(p, "in", 2) != 0 || !VIM_ISWHITE(p[2])) | |
6509 | + if (may_get_next_line_error(wp, &p, cctx) == FAIL) | |
6510 | + return NULL; | |
6511 | + if (STRNCMP(p, "in", 2) != 0 || !IS_WHITE_OR_NUL(p[2])) | |
6508 | 6512 | { |
6509 | 6513 | emsg(_(e_missing_in)); |
6510 | 6514 | return NULL; |
6511 | 6515 | } |
6512 | - p = skipwhite(p + 2); | |
6516 | + wp = p + 2; | |
6517 | + p = skipwhite(wp); | |
6518 | + if (may_get_next_line_error(wp, &p, cctx) == FAIL) | |
6519 | + return NULL; | |
6513 | 6520 | |
6514 | 6521 | scope = new_scope(cctx, FOR_SCOPE); |
6515 | 6522 | if (scope == NULL) |