summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-12-17 12:45:22 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-17 12:45:22 +0000
commit259f443a934c6f2447a14bfe54403903416a9af0 (patch)
treeda948110b6b10310d7d194845215ce7690057581
parentdeda6441e457072df39cdc8744dcd685d77fa273 (diff)
patch 8.2.3835: the inline-function example does not workv8.2.3835
Problem: The inline-function example does not work. Solution: Drop ":let". Add EX_EXPR_ARG to CMD_var. (issue #9352)
-rw-r--r--runtime/doc/vim9.txt9
-rw-r--r--src/ex_cmds.h2
-rw-r--r--src/testdir/test_vim9_expr.vim9
-rw-r--r--src/version.c2
4 files changed, 18 insertions, 4 deletions
diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt
index 990d759e6c..39affbfc2c 100644
--- a/runtime/doc/vim9.txt
+++ b/runtime/doc/vim9.txt
@@ -560,7 +560,6 @@ This can be useful for a timer, for example: >
echom 'Handler called ' .. count
}, {repeat: 3})
-
The ending "}" must be at the start of a line. It can be followed by other
characters, e.g.: >
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.
+ *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
written at the start of a line. Otherwise, it would be parsed as the end of
the block. This does not work: >
command NewCommand {
- let g:mydict = {
+ g:mydict = {
'key': 'value',
} # ERROR: will be recognized as the end of the block
}
Put the '}' after the last item to avoid this: >
command NewCommand {
- let g:mydict = {
+ g:mydict = {
'key': 'value' }
}
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
index c2657b0ff3..044580a7c1 100644
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -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,
ADDR_LINES),
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),
EXCMD(CMD_version, "version", ex_version,
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index e374788dba..685bde2ece 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -2557,10 +2557,19 @@ def Test_expr7_dict_in_block()
k: 0, }
}
MyCommand
+
+ command YourCommand {
+ g:global = {
+ key: 'value' }
+ }
+ YourCommand
+ assert_equal({key: 'value'}, g:global)
+ unlet g:global
END
CheckScriptSuccess(lines)
delcommand MyCommand
+ delcommand YourCommand
enddef
def Test_expr7_call_2bool()
diff --git a/src/version.c b/src/version.c
index 368384c9a2..7b2c484592 100644
--- a/src/version.c
+++ b/src/version.c
@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3835,
+/**/
3834,
/**/
3833,