diff options
-rw-r--r-- | runtime/doc/eval.txt | 15 | ||||
-rw-r--r-- | src/nvim/eval.c | 5 | ||||
-rw-r--r-- | src/nvim/testdir/test_method.vim | 10 |
3 files changed, 26 insertions, 4 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index a5940a963c..b397328bc0 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1053,12 +1053,19 @@ For methods that are also available as global functions this is the same as: > name(expr8 [, args]) There can also be methods specifically for the type of "expr8". -"->name(" must not contain white space. There can be white space before "->" -and after the "(". - -This allows for chaining, using the type that the method returns: > +This allows for chaining, passing the value that one method returns to the +next method: > mylist->filter(filterexpr)->map(mapexpr)->sort()->join() < + *E274* +"->name(" must not contain white space. There can be white space before the +"->" and after the "(", thus you can split the lines like this: > + mylist + \ ->filter(filterexpr) + \ ->map(mapexpr) + \ ->sort() + \ ->join() +< *expr9* number diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 4f934fdc70..23a0ef8506 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -4134,6 +4134,11 @@ static int eval_method(char_u **const arg, typval_T *const rettv, EMSG2(_(e_missingparen), name); } ret = FAIL; + } else if (ascii_iswhite((*arg)[-1])) { + if (verbose) { + EMSG(_("E274: No white space allowed before parenthesis")); + } + ret = FAIL; } else { ret = eval_func(arg, name, len, rettv, evaluate, &base); } diff --git a/src/nvim/testdir/test_method.vim b/src/nvim/testdir/test_method.vim index 142b259e78..58e86131dc 100644 --- a/src/nvim/testdir/test_method.vim +++ b/src/nvim/testdir/test_method.vim @@ -118,4 +118,14 @@ func Test_method_funcref() delfunc Concat endfunc +func Test_method_syntax() + eval [1, 2, 3] ->sort( ) + eval [1, 2, 3] + \ ->sort( + \ ) + call assert_fails('eval [1, 2, 3]-> sort()', 'E260:') + call assert_fails('eval [1, 2, 3]->sort ()', 'E274:') + call assert_fails('eval [1, 2, 3]-> sort ()', 'E260:') +endfunc + " vim: shiftwidth=2 sts=2 expandtab |