diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/option.c | 17 | ||||
-rw-r--r-- | src/testdir/test_vim9_script.vim | 39 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 57 insertions, 1 deletions
diff --git a/src/option.c b/src/option.c index 90e3e6d536..6232cd96d5 100644 --- a/src/option.c +++ b/src/option.c @@ -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; diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index f78eace212..a7e141e254 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -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 diff --git a/src/version.c b/src/version.c index 56c9f90ab3..1fb224326d 100644 --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3124, +/**/ 3123, /**/ 3122, |