Skip to content

Commit

Permalink
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Browse files Browse the repository at this point in the history
Problem:    Spaces allowed between option name and "!", "?", etc.
Solution:   Disallow spaces in Vim9 script, it was not documented.
            (closes #8408)
  • Loading branch information
brammool committed Jun 20, 2021
1 parent 2fb7495 commit 208f0b4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/option.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions src/testdir/test_vim9_script.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3021,
/**/
3020,
/**/
Expand Down

0 comments on commit 208f0b4

Please sign in to comment.