]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.3124: Vim9: no error for white space between option and "=9" v8.2.3124
authorBram Moolenaar <Bram@vim.org>
Thu, 8 Jul 2021 15:35:36 +0000 (17:35 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 8 Jul 2021 15:35:36 +0000 (17:35 +0200)
Problem:    Vim9: no error for white space between option and "=9".
Solution:   Check for extraneous white space. (issue #8408)

src/option.c
src/testdir/test_vim9_script.vim
src/version.c

index 90e3e6d5369e3a208148df801fcf5f9a5bb3c3dd..6232cd96d5491e88e8e00d1c72af2d73e5051157 100644 (file)
@@ -1358,7 +1358,22 @@ do_set(
            // remember character after option name
            afterchar = arg[len];
 
-           if (!in_vim9script())
+           if (in_vim9script())
+           {
+               char_u *p = skipwhite(arg + len);
+
+               // disallow white space before =val, +=val, -=val, ^=val
+               if (p > arg + len && (p[0] == '='
+                       || (vim_strchr((char_u *)"+-^", p[0]) != NULL
+                                                             && p[1] == '=')))
+               {
+                   errmsg = e_no_white_space_allowed_between_option_and;
+                   arg = p;
+                   startarg = p;
+                   goto skip;
+               }
+           }
+           else
                // skip white space, allow ":set ai  ?", ":set hlsearch  !"
                while (VIM_ISWHITE(arg[len]))
                    ++len;
index f78eace212badda446b8411bd2535a8bec4fe9f9..a7e141e254cc059b2ff44c89265c0edaab9a15ee 100644 (file)
@@ -4075,6 +4075,45 @@ def Test_mapping_line_number()
   delfunc g:FuncA
 enddef
 
+def Test_option_set()
+  # legacy script allows for white space
+  var lines =<< trim END
+      set foldlevel  =11
+      call assert_equal(11, &foldlevel)
+  END
+  CheckScriptSuccess(lines)
+
+  set foldlevel
+  set foldlevel=12
+  assert_equal(12, &foldlevel)
+  set foldlevel+=2
+  assert_equal(14, &foldlevel)
+  set foldlevel-=3
+  assert_equal(11, &foldlevel)
+
+  lines =<< trim END
+      set foldlevel =1
+  END
+  CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: =1')
+
+  lines =<< trim END
+      set foldlevel +=1
+  END
+  CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: +=1')
+
+  lines =<< trim END
+      set foldlevel ^=1
+  END
+  CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: ^=1')
+
+  lines =<< trim END
+      set foldlevel -=1
+  END
+  CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: -=1')
+
+  set foldlevel&
+enddef
+
 def Test_option_modifier()
   # legacy script allows for white space
   var lines =<< trim END
index 56c9f90ab3805cedee59e703f1657b92f42ac09f..1fb224326d19a4936347114cd67893d8460ff767 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3124,
 /**/
     3123,
 /**/