]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0799: in compiled function ->() on next line not recognized v9.0.0799
authorBram Moolenaar <Bram@vim.org>
Wed, 19 Oct 2022 17:04:49 +0000 (18:04 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 19 Oct 2022 17:04:49 +0000 (18:04 +0100)
Problem:    In compiled function ->() on next line not recognized.
Solution:   Also check for "(". (closes #11405)

src/testdir/test_lambda.vim
src/version.c
src/vim9expr.c

index 3e348a0a0131a01a16aecb401ad770f3380c48d8..250ce5c481640ea0f077dc018bccd48899d585a9 100644 (file)
@@ -82,6 +82,23 @@ func Test_lambda_vim9cmd_linebreak()
   call v9.CheckDefAndScriptSuccess(lines)
 endfunc
 
+def Test_lamba_compiled_linebreak()
+  var lines =<< trim END
+      vim9script
+
+      def Echo(what: any)
+        assert_equal('hello world', what)
+      enddef
+      def That()
+        printf("hello ")
+          ->((x) => x .. "world")()
+          ->Echo()
+      enddef
+      That()
+  END
+  v9.CheckScriptSuccess(lines)
+enddef
+
 func Test_lambda_with_partial()
   let l:Cb = function({... -> ['zero', a:1, a:2, a:3]}, ['one', 'two'])
   call assert_equal(['zero', 'one', 'two', 'three'], l:Cb('three'))
index e612e53661cca11e24732ae35c6b3e46860c971e..c068ac3fed1894071baa3b5b7e0689b5b0991cd6 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    799,
 /**/
     798,
 /**/
index 854c09d01c09db649a2d6739e5ec99c34793e335..1fbe05b0727d97c55ba02af64aaba43cd26c89a6 100644 (file)
@@ -1788,12 +1788,13 @@ compile_subscript(
        {
            char_u *next = peek_next_line_from_context(cctx);
 
-           // If a following line starts with "->{" or "->X" advance to that
-           // line, so that a line break before "->" is allowed.
+           // If a following line starts with "->{", "->(" or "->X" advance to
+           // that line, so that a line break before "->" is allowed.
            // Also if a following line starts with ".x".
            if (next != NULL &&
                    ((next[0] == '-' && next[1] == '>'
                                 && (next[2] == '{'
+                                      || next[2] == '('
                                       || ASCII_ISALPHA(*skipwhite(next + 2))))
                    || (next[0] == '.' && eval_isdictc(next[1]))))
            {