Patch 8.2.3124
Problem:    Vim9: no error for white space between option and "=9".
Solution:   Check for extraneous white space. (issue #8408)
Files:      src/option.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.3123/src/option.c        2021-07-08 16:40:01.073808495 +0200
--- src/option.c        2021-07-08 17:28:10.716949420 +0200
***************
*** 1358,1364 ****
            // remember character after option name
            afterchar = arg[len];
  
!           if (!in_vim9script())
                // skip white space, allow ":set ai  ?", ":set hlsearch  !"
                while (VIM_ISWHITE(arg[len]))
                    ++len;
--- 1358,1379 ----
            // remember character after option name
            afterchar = arg[len];
  
!           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;
*** ../vim-8.2.3123/src/testdir/test_vim9_script.vim    2021-07-08 
16:40:01.073808495 +0200
--- src/testdir/test_vim9_script.vim    2021-07-08 17:24:42.709293816 +0200
***************
*** 4075,4080 ****
--- 4075,4119 ----
    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
*** ../vim-8.2.3123/src/version.c       2021-07-08 16:40:01.077808506 +0200
--- src/version.c       2021-07-08 17:31:29.040673390 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3124,
  /**/

-- 
>From "know your smileys":
 :-*    A big kiss!

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202107081536.168Fa5RG045812%40masaka.moolenaar.net.

Raspunde prin e-mail lui