]> granicus.if.org Git - vim/commitdiff
patch 8.2.3021: spaces allowed between option name and "!", "?", etc. v8.2.3021
authorBram Moolenaar <Bram@vim.org>
Sun, 20 Jun 2021 10:40:08 +0000 (12:40 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 20 Jun 2021 10:40:08 +0000 (12:40 +0200)
Problem:    Spaces allowed between option name and "!", "?", etc.
Solution:   Disallow spaces in Vim9 script, it was not documented.
            (closes #8408)

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

index dd44fe4ac4441b0828a928c486b563b5befff570..535213c19df50de4f8561d5b2c295b7a8bb1a033 100644 (file)
@@ -1306,9 +1306,10 @@ do_set(
            // remember character after option name
            afterchar = arg[len];
 
-           // skip white space, allow ":set ai  ?"
-           while (VIM_ISWHITE(arg[len]))
-               ++len;
+           if (!in_vim9script())
+               // skip white space, allow ":set ai  ?", ":set hlsearch  !"
+               while (VIM_ISWHITE(arg[len]))
+                   ++len;
 
            adding = FALSE;
            prepending = FALSE;
index 4b0ab2bad71cbc890df90d521d8c32ab67c98b98..1584f173a8033ea77623cd731ffe39806d5ee7c9 100644 (file)
@@ -3937,6 +3937,26 @@ def Test_mapping_line_number()
   delfunc g:FuncA
 enddef
 
+def Test_option_modifier()
+  var lines =<< trim END
+      set hlsearch &  hlsearch  !
+      call assert_equal(1, &hlsearch)
+  END
+  CheckScriptSuccess(lines)
+
+  lines =<< trim END
+      vim9script
+      set hlsearch &
+  END
+  CheckScriptFailure(lines, 'E518:')
+
+  lines =<< trim END
+      vim9script
+      set hlsearch &  hlsearch  !
+  END
+  CheckScriptFailure(lines, 'E518:')
+enddef
+
 " Keep this last, it messes up highlighting.
 def Test_substitute_cmd()
   new
index d1201f4f6b9b50350912ea076e1416e222638c54..d217fe615b4992100d3436f39cd20ce6923cf949 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3021,
 /**/
     3020,
 /**/