mirror of
https://github.com/vim/vim.git
synced 2025-10-02 05:04:20 -04:00
patch 9.0.0423: "for" and "while" not recognized after :vim9cmd and :legacy
Problem: "for" and "while" not recognized after :vim9cmd and :legacy. (Emanuele Torre) Solution: Recognize all the command modifiers. (closes #11087) Add a test to check the list of modifiers.
This commit is contained in:
@@ -2888,7 +2888,7 @@ parse_command_modifiers(
|
||||
|
||||
switch (*p)
|
||||
{
|
||||
// When adding an entry, also modify cmd_exists().
|
||||
// When adding an entry, also modify cmdmods[].
|
||||
case 'a': if (!checkforcmd_noparen(&eap->cmd, "aboveleft", 3))
|
||||
break;
|
||||
cmod->cmod_split |= WSP_ABOVE;
|
||||
@@ -3958,11 +3958,13 @@ static struct cmdmod
|
||||
{"confirm", 4, FALSE},
|
||||
{"filter", 4, FALSE},
|
||||
{"hide", 3, FALSE},
|
||||
{"horizontal", 3, FALSE},
|
||||
{"keepalt", 5, FALSE},
|
||||
{"keepjumps", 5, FALSE},
|
||||
{"keepmarks", 3, FALSE},
|
||||
{"keeppatterns", 5, FALSE},
|
||||
{"leftabove", 5, FALSE},
|
||||
{"legacy", 3, FALSE},
|
||||
{"lockmarks", 3, FALSE},
|
||||
{"noautocmd", 3, FALSE},
|
||||
{"noswapfile", 3, FALSE},
|
||||
@@ -3974,6 +3976,7 @@ static struct cmdmod
|
||||
{"unsilent", 3, FALSE},
|
||||
{"verbose", 4, TRUE},
|
||||
{"vertical", 4, FALSE},
|
||||
{"vim9cmd", 4, FALSE},
|
||||
};
|
||||
|
||||
/*
|
||||
|
@@ -87,6 +87,7 @@ NEW_TESTS = \
|
||||
test_clientserver \
|
||||
test_close_count \
|
||||
test_cmdline \
|
||||
test_cmdmods \
|
||||
test_cmdwin \
|
||||
test_command_count \
|
||||
test_comments \
|
||||
@@ -346,6 +347,7 @@ NEW_TESTS_RES = \
|
||||
test_clientserver.res \
|
||||
test_close_count.res \
|
||||
test_cmdline.res \
|
||||
test_cmdmods.res \
|
||||
test_cmdwin.res \
|
||||
test_command_count.res \
|
||||
test_comments.res \
|
||||
|
35
src/testdir/test_cmdmods.vim
Normal file
35
src/testdir/test_cmdmods.vim
Normal file
@@ -0,0 +1,35 @@
|
||||
" Test for all comand modifiers in
|
||||
|
||||
def Test_cmdmods_array()
|
||||
# Get all the command modifiers from ex_cmds.h.
|
||||
var lines = readfile('../ex_cmds.h')->filter((_, l) => l =~ 'ex_wrongmodifier,')
|
||||
var cmds = lines->map((_, v) => substitute(v, '.*"\(\k*\)".*', '\1', ''))
|
||||
|
||||
# :hide is both a command and a modifier
|
||||
cmds->extend(['hide'])
|
||||
|
||||
# Get the entries of cmdmods[] in ex_docmd.c
|
||||
edit ../ex_docmd.c
|
||||
var top = search('^} cmdmods[') + 1
|
||||
var bot = search('^};') - 1
|
||||
lines = getline(top, bot)
|
||||
var mods = lines->map((_, v) => substitute(v, '.*"\(\k*\)".*', '\1', ''))
|
||||
|
||||
# Check the lists are equal. Convert them to a dict to get a clearer error
|
||||
# message.
|
||||
var cmds_dict = {}
|
||||
for v in cmds
|
||||
cmds_dict[v] = 1
|
||||
endfor
|
||||
var mods_dict = {}
|
||||
for v in mods
|
||||
mods_dict[v] = 1
|
||||
endfor
|
||||
assert_equal(cmds_dict, mods_dict)
|
||||
|
||||
bwipe!
|
||||
enddef
|
||||
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@@ -146,6 +146,15 @@ func Test_for_over_null_string()
|
||||
let &enc = save_enc
|
||||
endfunc
|
||||
|
||||
func Test_for_with_modifier()
|
||||
" this checks has_loop_cmd() works with a modifier
|
||||
let result = []
|
||||
vim9cmd for i in range(3)
|
||||
call extend(result, [i])
|
||||
endfor
|
||||
call assert_equal([0, 1, 2], result)
|
||||
endfunc
|
||||
|
||||
func Test_for_invalid_line_count()
|
||||
let lines =<< trim END
|
||||
111111111111111111111111 for line in ['one']
|
||||
|
@@ -703,6 +703,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
423,
|
||||
/**/
|
||||
422,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user