Skip to content

Commit 208f0b4

Browse files
committed
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Problem: Spaces allowed between option name and "!", "?", etc. Solution: Disallow spaces in Vim9 script, it was not documented. (closes #8408)
1 parent 2fb7495 commit 208f0b4

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/option.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,9 +1306,10 @@ do_set(
13061306
// remember character after option name
13071307
afterchar = arg[len];
13081308

1309-
// skip white space, allow ":set ai ?"
1310-
while (VIM_ISWHITE(arg[len]))
1311-
++len;
1309+
if (!in_vim9script())
1310+
// skip white space, allow ":set ai ?", ":set hlsearch !"
1311+
while (VIM_ISWHITE(arg[len]))
1312+
++len;
13121313

13131314
adding = FALSE;
13141315
prepending = FALSE;

src/testdir/test_vim9_script.vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3937,6 +3937,26 @@ def Test_mapping_line_number()
39373937
delfunc g:FuncA
39383938
enddef
39393939

3940+
def Test_option_modifier()
3941+
var lines =<< trim END
3942+
set hlsearch & hlsearch !
3943+
call assert_equal(1, &hlsearch)
3944+
END
3945+
CheckScriptSuccess(lines)
3946+
3947+
lines =<< trim END
3948+
vim9script
3949+
set hlsearch &
3950+
END
3951+
CheckScriptFailure(lines, 'E518:')
3952+
3953+
lines =<< trim END
3954+
vim9script
3955+
set hlsearch & hlsearch !
3956+
END
3957+
CheckScriptFailure(lines, 'E518:')
3958+
enddef
3959+
39403960
" Keep this last, it messes up highlighting.
39413961
def Test_substitute_cmd()
39423962
new

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
3021,
753755
/**/
754756
3020,
755757
/**/

0 commit comments

Comments
 (0)