diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-06-21 14:12:17 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-06-21 14:12:17 +0200 |
commit | a3b7fdc1bb227897f41b8f2958a48d0a26292ff7 (patch) | |
tree | bfd75225d48665c287712d7befc34d902d77e76d | |
parent | 8c524f76ebd43f006e765534765b595de7095f12 (diff) | |
download | vim-git-a3b7fdc1bb227897f41b8f2958a48d0a26292ff7.tar.gz |
patch 8.2.1026: Vim9: cannot break the line after "->"v8.2.1026
Problem: Vim9: cannot break the line after "->".
Solution: Check for a continuation line after "->", "[" and ".". Ignore
trailing white space.
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 15 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 17 |
3 files changed, 30 insertions, 4 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 224f4fda0..05a3cd6d3 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1029,6 +1029,21 @@ def Test_expr7_trailing() assert_equal(123, d.key) enddef +def Test_expr7_subscript_linebreak() + let range = range( + 3) + let l = range-> + map('string(v:key)') + assert_equal(['0', '1', '2'], l) + + assert_equal('1', l[ + 1]) + + let d = #{one: 33} + assert_equal(33, d. + one) +enddef + func Test_expr7_trailing_fails() call CheckDefFailure(['let l = [2]', 'l->{l -> add(l, 8)}'], 'E107') diff --git a/src/version.c b/src/version.c index 1a936ec9c..dad247833 100644 --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1026, +/**/ 1025, /**/ 1024, diff --git a/src/vim9compile.c b/src/vim9compile.c index 54f47b9b9..5b440940e 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -3538,7 +3538,10 @@ compile_subscript( return FAIL; *start_leader = end_leader; // don't apply again later - *arg = skipwhite(*arg + 2); + p = *arg + 2; + *arg = skipwhite(p); + if (may_get_next_line(p, arg, cctx) == FAIL) + return FAIL; if (**arg == '{') { // lambda call: list->{lambda} @@ -3567,6 +3570,7 @@ compile_subscript( { garray_T *stack = &cctx->ctx_type_stack; type_T **typep; + char_u *p; // list index: list[123] // dict member: dict[key] @@ -3576,7 +3580,10 @@ compile_subscript( if (generate_ppconst(cctx, ppconst) == FAIL) return FAIL; - *arg = skipwhite(*arg + 1); + p = *arg + 1; + *arg = skipwhite(p); + if (may_get_next_line(p, arg, cctx) == FAIL) + return FAIL; if (compile_expr0(arg, cctx) == FAIL) return FAIL; @@ -3617,8 +3624,10 @@ compile_subscript( return FAIL; ++*arg; - p = *arg; + if (may_get_next_line(*arg, arg, cctx) == FAIL) + return FAIL; // dictionary member: dict.name + p = *arg; if (eval_isnamec1(*p)) while (eval_isnamec(*p)) MB_PTR_ADV(p); @@ -6664,7 +6673,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx) if (line != NULL && *line == '|') // the line continues after a '|' ++line; - else if (line != NULL && *line != NUL + else if (line != NULL && *skipwhite(line) != NUL && !(*line == '#' && (line == cctx.ctx_line_start || VIM_ISWHITE(line[-1])))) { |