changeset 21391:8b882afa8ed2 v8.2.1246

patch 8.2.1246: Vim9: comment after assignment doesn't work Commit: https://github.com/vim/vim/commit/b209750b5e907003568c20856215122670ee22d2 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 19 17:17:02 2020 +0200 patch 8.2.1246: Vim9: comment after assignment doesn't work Problem: Vim9: comment after assignment doesn't work. Solution: Skip over white space. (closes https://github.com/vim/vim/issues/6481)
author Bram Moolenaar <Bram@vim.org>
date Sun, 19 Jul 2020 17:30:03 +0200
parents 00c6c02dc0b8
children 6b34289ace89
files src/testdir/test_vim9_script.vim src/version.c src/vim9compile.c
diffstat 3 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -29,7 +29,7 @@ def Test_assignment()
   call CheckDefFailure(['let x:string = "x"'], 'E1069:')
   call CheckDefFailure(['let a:string = "x"'], 'E1069:')
 
-  let a: number = 6
+  let a: number = 6 #comment
   assert_equal(6, a)
 
   if has('channel')
@@ -44,7 +44,7 @@ def Test_assignment()
   let Funky2: func = function('len')
   let Party2: func = funcref('g:Test_syntax')
 
-  g:newvar = 'new'
+  g:newvar = 'new'  #comment
   assert_equal('new', g:newvar)
 
   assert_equal('yes', g:existing)
@@ -821,6 +821,22 @@ def Test_cexpr_vimscript()
   set errorformat&
 enddef
 
+def Test_list_vimscript()
+  # checks line continuation and comments
+  let lines =<< trim END
+      vim9script
+      let mylist = [
+            'one',
+            # comment
+            'two', # empty line follows
+
+            'three',
+            ]
+      assert_equal(['one', 'two', 'three'], mylist)
+  END
+  CheckScriptSuccess(lines)
+enddef
+
 if has('channel')
   let someJob = test_null_job()
 
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1246,
+/**/
     1245,
 /**/
     1244,
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -5706,7 +5706,7 @@ compile_assignment(char_u *arg, exarg_T 
 	    goto theend;
     }
 
-    ret = end;
+    ret = skipwhite(end);
 
 theend:
     vim_free(name);