• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révisionb3124656f050c31293b3dbd4a97235c019dfb50f (tree)
l'heure2020-12-02 21:30:04
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

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

patch 8.2.2079: Vim9: cannot put a linebreak before or after "in" of ":for"
Problem: Vim9: cannot put a linebreak before or after "in" of ":for".
Solution: Skip over linebreak.

Change Summary

Modification

diff -r 916779898006 -r b3124656f050 src/testdir/test_vim9_script.vim
--- a/src/testdir/test_vim9_script.vim Wed Dec 02 12:45:04 2020 +0100
+++ b/src/testdir/test_vim9_script.vim Wed Dec 02 13:30:04 2020 +0100
@@ -1849,6 +1849,28 @@
18491849 concat ..= str
18501850 endfor
18511851 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)
18521874 enddef
18531875
18541876 def Test_for_loop_fails()
diff -r 916779898006 -r b3124656f050 src/version.c
--- a/src/version.c Wed Dec 02 12:45:04 2020 +0100
+++ b/src/version.c Wed Dec 02 13:30:04 2020 +0100
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 2079,
755+/**/
754756 2078,
755757 /**/
756758 2077,
diff -r 916779898006 -r b3124656f050 src/vim9compile.c
--- a/src/vim9compile.c Wed Dec 02 12:45:04 2020 +0100
+++ b/src/vim9compile.c Wed Dec 02 13:30:04 2020 +0100
@@ -6486,6 +6486,7 @@
64866486 char_u *arg_end;
64876487 char_u *name = NULL;
64886488 char_u *p;
6489+ char_u *wp;
64896490 int var_count = 0;
64906491 int semicolon = FALSE;
64916492 size_t varlen;
@@ -6503,13 +6504,19 @@
65036504 var_count = 1;
65046505
65056506 // consume "in"
6507+ wp = p;
65066508 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]))
65086512 {
65096513 emsg(_(e_missing_in));
65106514 return NULL;
65116515 }
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;
65136520
65146521 scope = new_scope(cctx, FOR_SCOPE);
65156522 if (scope == NULL)
Afficher sur ancien navigateur de dépôt.