changeset 25396:8ecd3575bc8c v8.2.3235

patch 8.2.3235: cannot use lambda in {} block in user command Commit: https://github.com/vim/vim/commit/6868634abd6a49b2dfd3a994a6da7d5911457a37 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jul 28 15:54:54 2021 +0200 patch 8.2.3235: cannot use lambda in {} block in user command Problem: Cannot use lambda in {} block in user command. (Martin Tournoij) Solution: Do not go over the end of the lambda.
author Bram Moolenaar <Bram@vim.org>
date Wed, 28 Jul 2021 16:00:05 +0200
parents 8312a5e2eef2
children 51a3d4ad3a36
files src/testdir/test_usercommands.vim src/userfunc.c src/version.c
diffstat 3 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_usercommands.vim
+++ b/src/testdir/test_usercommands.vim
@@ -632,6 +632,13 @@ func Test_usercmd_with_block()
   call assert_equal('more', g:didmore)
   unlet g:didit
   unlet g:didmore
+  delcommand DoSomething
+
+  command DoMap {
+	echo [1, 2, 3]->map((_, v) => v + 1)
+    }
+  DoMap
+  delcommand DoMap
 
   let lines =<< trim END
       command DoesNotEnd {
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -1398,7 +1398,7 @@ get_lambda_tv(
 
 	// If there are line breaks, we need to split up the string.
 	line_end = vim_strchr(start, '\n');
-	if (line_end == NULL)
+	if (line_end == NULL || line_end > end)
 	    line_end = end;
 
 	// Add "return " before the expression (or the first line).
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3235,
+/**/
     3234,
 /**/
     3233,