0
0
mirror of https://github.com/vim/vim.git synced 2025-10-04 05:25:06 -04:00

patch 8.2.3835: the inline-function example does not work

Problem:    The inline-function example does not work.
Solution:   Drop ":let".  Add EX_EXPR_ARG to CMD_var. (issue #9352)
This commit is contained in:
Bram Moolenaar
2021-12-17 12:45:22 +00:00
parent deda6441e4
commit 259f443a93
4 changed files with 18 additions and 4 deletions

View File

@@ -560,7 +560,6 @@ This can be useful for a timer, for example: >
echom 'Handler called ' .. count echom 'Handler called ' .. count
}, {repeat: 3}) }, {repeat: 3})
The ending "}" must be at the start of a line. It can be followed by other The ending "}" must be at the start of a line. It can be followed by other
characters, e.g.: > characters, e.g.: >
var d = mapnew(dict, (k, v): string => { var d = mapnew(dict, (k, v): string => {
@@ -568,17 +567,21 @@ characters, e.g.: >
}) })
No command can follow the "{", only a comment can be used there. No command can follow the "{", only a comment can be used there.
*command-block*
The block can also be used for defining a user command. Inside the block Vim9
syntax will be used.
If the statements include a dictionary, its closing bracket must not be If the statements include a dictionary, its closing bracket must not be
written at the start of a line. Otherwise, it would be parsed as the end of written at the start of a line. Otherwise, it would be parsed as the end of
the block. This does not work: > the block. This does not work: >
command NewCommand { command NewCommand {
let g:mydict = { g:mydict = {
'key': 'value', 'key': 'value',
} # ERROR: will be recognized as the end of the block } # ERROR: will be recognized as the end of the block
} }
Put the '}' after the last item to avoid this: > Put the '}' after the last item to avoid this: >
command NewCommand { command NewCommand {
let g:mydict = { g:mydict = {
'key': 'value' } 'key': 'value' }
} }

View File

@@ -1691,7 +1691,7 @@ EXCMD(CMD_vglobal, "vglobal", ex_global,
EX_RANGE|EX_WHOLEFOLD|EX_EXTRA|EX_DFLALL|EX_CMDWIN|EX_LOCK_OK|EX_NONWHITE_OK, EX_RANGE|EX_WHOLEFOLD|EX_EXTRA|EX_DFLALL|EX_CMDWIN|EX_LOCK_OK|EX_NONWHITE_OK,
ADDR_LINES), ADDR_LINES),
EXCMD(CMD_var, "var", ex_var, EXCMD(CMD_var, "var", ex_var,
EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK, EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE), ADDR_NONE),
EXCMD(CMD_version, "version", ex_version, EXCMD(CMD_version, "version", ex_version,
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK, EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,

View File

@@ -2557,10 +2557,19 @@ def Test_expr7_dict_in_block()
k: 0, } k: 0, }
} }
MyCommand MyCommand
command YourCommand {
g:global = {
key: 'value' }
}
YourCommand
assert_equal({key: 'value'}, g:global)
unlet g:global
END END
CheckScriptSuccess(lines) CheckScriptSuccess(lines)
delcommand MyCommand delcommand MyCommand
delcommand YourCommand
enddef enddef
def Test_expr7_call_2bool() def Test_expr7_call_2bool()

View File

@@ -749,6 +749,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3835,
/**/ /**/
3834, 3834,
/**/ /**/