]> granicus.if.org Git - vim/commitdiff
patch 8.2.3235: cannot use lambda in {} block in user command v8.2.3235
authorBram Moolenaar <Bram@vim.org>
Wed, 28 Jul 2021 13:54:54 +0000 (15:54 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 28 Jul 2021 13:54:54 +0000 (15:54 +0200)
Problem:    Cannot use lambda in {} block in user command. (Martin Tournoij)
Solution:   Do not go over the end of the lambda.

src/testdir/test_usercommands.vim
src/userfunc.c
src/version.c

index df8893709df28543d07b279156e6741e48d1bfcd..173b23ed2ed27a255a49b4456b3435d97fcac16b 100644 (file)
@@ -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 {
index 7c9634742bdfc419dc6e4d389012ad760ae712b3..e008718835c17b4a8331fb952aff0cd3905a5443 100644 (file)
@@ -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).
index fa54081cae907bf13832d50b7f648abc45cad5c3..ea232c37ba1d054453185503b51fb99658fd56f3 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3235,
 /**/
     3234,
 /**/