diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-01-08 22:24:19 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-01-08 22:24:19 +0100 |
commit | b657198cb30765468451d7f68fce49b5b4000c5d (patch) | |
tree | f08af40d882cbc7e6d0d0f2cc4c0df691bcf7491 | |
parent | 832ea89ca90cdff019ee7cf31d5c44bfa164313a (diff) | |
download | vim-git-b657198cb30765468451d7f68fce49b5b4000c5d.tar.gz |
patch 8.2.2316: Vim9: cannot list a lambda functionv8.2.2316
Problem: Vim9: cannot list a lambda function.
Solution: Support the <lambda>9 notation, like :disassemble. (closes #7634)
-rw-r--r-- | src/testdir/test_vim9_func.vim | 10 | ||||
-rw-r--r-- | src/userfunc.c | 10 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 21 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index fb37401a2..3d4f4c9b7 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -1802,6 +1802,16 @@ def Test_line_continuation_in_lambda() Line_continuation_in_lambda()->assert_equal(['D', 'C', 'B', 'A']) enddef +def Test_list_lambda() + timer_start(1000, (_) => 0) + var body = execute(timer_info()[0].callback + ->string() + ->substitute("('", ' ', '') + ->substitute("')", '', '') + ->substitute('function\zs', ' ', '')) + assert_match('def <lambda>\d\+(_: any, ...): number\n1 return 0\n enddef', body) +enddef + func Test_silent_echo() CheckScreendump diff --git a/src/userfunc.c b/src/userfunc.c index 1918e541f..ded9ef7b0 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -3094,7 +3094,15 @@ define_function(exarg_T *eap, char_u *name_arg) } else { - name = trans_function_name(&p, &is_global, eap->skip, + if (STRNCMP(p, "<lambda>", 8) == 0) + { + p += 8; + (void)getdigits(&p); + name = vim_strnsave(eap->arg, p - eap->arg); + CLEAR_FIELD(fudi); + } + else + name = trans_function_name(&p, &is_global, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL, NULL); paren = (vim_strchr(p, '(') != NULL); if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) diff --git a/src/version.c b/src/version.c index 107866595..f4cfa2ba0 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2316, +/**/ 2315, /**/ 2314, |