mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 9.0.1081: using "->" with split lines does not always work
Problem: Using "->" with split lines does not always work. Solution: Avoid trying to get another line. (closes #11723)
This commit is contained in:
17
src/eval.c
17
src/eval.c
@@ -4548,11 +4548,19 @@ eval_method(
|
||||
if (**arg != '(' && alias == NULL
|
||||
&& (paren = vim_strchr(*arg, '(')) != NULL)
|
||||
{
|
||||
char_u *deref;
|
||||
|
||||
*arg = name;
|
||||
|
||||
// Truncate the name a the "(". Avoid trying to get another line
|
||||
// by making "getline" NULL.
|
||||
*paren = NUL;
|
||||
deref = deref_function_name(arg, &tofree, evalarg, verbose);
|
||||
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,7 +4571,10 @@ eval_method(
|
||||
name = deref;
|
||||
len = (long)STRLEN(name);
|
||||
}
|
||||
|
||||
*paren = '(';
|
||||
if (getline != NULL)
|
||||
evalarg->eval_getline = getline;
|
||||
}
|
||||
|
||||
if (ret == OK)
|
||||
|
@@ -179,6 +179,60 @@ func Test_user_method()
|
||||
eval 'bar'->s:addFoo()->assert_equal('barfoo')
|
||||
endfunc
|
||||
|
||||
func Test_method_with_linebreaks()
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
|
||||
export def Scan(ll: list<number>): func(func(number))
|
||||
return (Emit: func(number)) => {
|
||||
for v in ll
|
||||
Emit(v)
|
||||
endfor
|
||||
}
|
||||
enddef
|
||||
|
||||
export def Build(Cont: func(func(number))): list<number>
|
||||
var result: list<number> = []
|
||||
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
|
||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1081,
|
||||
/**/
|
||||
1080,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user