To: vim_dev@googlegroups.com Subject: Patch 9.0.1081 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1081 Problem: Using "->" with split lines does not always work. Solution: Avoid trying to get another line. (closes #11723) Files: src/eval.c, src/testdir/test_user_func.vim *** ../vim-9.0.1080/src/eval.c 2022-12-18 21:42:49.010716927 +0000 --- src/eval.c 2022-12-19 20:26:08.073476338 +0000 *************** *** 4548,4558 **** if (**arg != '(' && alias == NULL && (paren = vim_strchr(*arg, '(')) != NULL) { - char_u *deref; - *arg = name; *paren = NUL; ! deref = deref_function_name(arg, &tofree, evalarg, verbose); if (deref == NULL) { *arg = name + len; --- 4548,4566 ---- if (**arg != '(' && alias == NULL && (paren = vim_strchr(*arg, '(')) != NULL) { *arg = name; + + // Truncate the name a the "(". Avoid trying to get another line + // by making "getline" NULL. *paren = NUL; ! char_u *(*getline)(int, void *, int, getline_opt_T) = NULL; ! if (evalarg != NULL) ! { ! getline = evalarg->eval_getline; ! evalarg->eval_getline = NULL; ! } ! ! char_u *deref = deref_function_name(arg, &tofree, evalarg, verbose); if (deref == NULL) { *arg = name + len; *************** *** 4563,4569 **** --- 4571,4580 ---- name = deref; len = (long)STRLEN(name); } + *paren = '('; + if (getline != NULL) + evalarg->eval_getline = getline; } if (ret == OK) *** ../vim-9.0.1080/src/testdir/test_user_func.vim 2022-10-15 21:35:51.191403811 +0100 --- src/testdir/test_user_func.vim 2022-12-19 20:25:13.369634729 +0000 *************** *** 179,184 **** --- 179,238 ---- eval 'bar'->s:addFoo()->assert_equal('barfoo') endfunc + func Test_method_with_linebreaks() + let lines =<< trim END + vim9script + + export def Scan(ll: list): func(func(number)) + return (Emit: func(number)) => { + for v in ll + Emit(v) + endfor + } + enddef + + export def Build(Cont: func(func(number))): list + var result: list = [] + Cont((v) => { + add(result, v) + }) + return result + enddef + + export def Noop(Cont: func(func(number))): func(func(number)) + return (Emit: func(number)) => { + Cont(Emit) + } + enddef + END + call writefile(lines, 'Xlib.vim', 'D') + + let lines =<< trim END + vim9script + + import "./Xlib.vim" as lib + + const x = [1, 2, 3] + + var result = lib.Scan(x)->lib.Noop()->lib.Build() + assert_equal([1, 2, 3], result) + + result = lib.Scan(x)->lib.Noop() + ->lib.Build() + assert_equal([1, 2, 3], result) + + result = lib.Scan(x) + ->lib.Noop()->lib.Build() + assert_equal([1, 2, 3], result) + + result = lib.Scan(x) + ->lib.Noop() + ->lib.Build() + assert_equal([1, 2, 3], result) + END + call v9.CheckScriptSuccess(lines) + endfunc + func Test_failed_call_in_try() try | call UnknownFunc() | catch | endtry endfunc *** ../vim-9.0.1080/src/version.c 2022-12-19 18:56:44.173594364 +0000 --- src/version.c 2022-12-19 20:26:23.833433379 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1081, /**/ -- The question is: What do you do with your life? The wrong answer is: Become the richest guy in the graveyard. (billionaire and Oracle founder Larry Ellison) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///