Skip to content

Commit 148be9b

Browse files
committed
patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Problem: Vim9: a variable name with "->" in the next line doesn't work. Solution: Recognize a variable name by itself. (closes #7770)
1 parent d5e8c92 commit 148be9b

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

src/ex_docmd.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3424,6 +3424,16 @@ find_ex_command(
34243424
return eap->cmd;
34253425
}
34263426
}
3427+
3428+
// If it is an ID it might be a variable with an operator on the next
3429+
// line, if the variable exists it can't be an Ex command.
3430+
if (p > eap->cmd && ends_excmd(*skipwhite(p))
3431+
&& (lookup(eap->cmd, p - eap->cmd, NULL, cctx) == OK
3432+
|| (ASCII_ISALPHA(eap->cmd[0]) && eap->cmd[1] == ':')))
3433+
{
3434+
eap->cmdidx = CMD_eval;
3435+
return eap->cmd;
3436+
}
34273437
}
34283438
#endif
34293439

src/testdir/test_vim9_cmd.vim

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,29 @@ def Test_method_call_linebreak()
328328
assert_equal([1, 2, 3], res)
329329
END
330330
CheckScriptSuccess(lines)
331+
332+
lines =<< trim END
333+
new
334+
var name = [1, 2]
335+
name
336+
->copy()
337+
->setline(1)
338+
assert_equal(['1', '2'], getline(1, 2))
339+
bwipe!
340+
END
341+
CheckDefAndScriptSuccess(lines)
342+
343+
lines =<< trim END
344+
new
345+
g:shortlist
346+
->copy()
347+
->setline(1)
348+
assert_equal(['1', '2'], getline(1, 2))
349+
bwipe!
350+
END
351+
g:shortlist = [1, 2]
352+
CheckDefAndScriptSuccess(lines)
353+
unlet g:shortlist
331354
enddef
332355

333356
def Test_method_call_whitespace()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2453,
753755
/**/
754756
2452,
755757
/**/

0 commit comments

Comments
 (0)