1
0
forked from aniani/vim

patch 8.2.2964: Vim9: hang when using space after ->

Problem:    Vim9: hang when using space after ->. (Naohiro Ono)
Solution:   Skip over white space to find the function name. (closes #8341)
This commit is contained in:
Bram Moolenaar
2021-06-08 20:46:45 +02:00
parent 445f11d5bc
commit a733042b12
4 changed files with 11 additions and 3 deletions

View File

@@ -5786,8 +5786,9 @@ handle_subscript(
p = eval_next_non_blank(*arg, evalarg, &getnext); p = eval_next_non_blank(*arg, evalarg, &getnext);
if (getnext if (getnext
&& ((rettv->v_type == VAR_DICT && *p == '.' && eval_isdictc(p[1])) && ((rettv->v_type == VAR_DICT && *p == '.' && eval_isdictc(p[1]))
|| (p[0] == '-' && p[1] == '>' || (p[0] == '-' && p[1] == '>' && (p[2] == '{'
&& (p[2] == '{' || ASCII_ISALPHA(p[2]))))) || ASCII_ISALPHA(in_vim9script() ? *skipwhite(p + 2)
: p[2])))))
{ {
*arg = eval_next_line(evalarg); *arg = eval_next_line(evalarg);
p = *arg; p = *arg;

View File

@@ -2961,6 +2961,10 @@ def Test_expr7_method_call()
var Join = (l) => join(l, 'x') var Join = (l) => join(l, 'x')
assert_equal('axb', ['a', 'b']->(Join)()) assert_equal('axb', ['a', 'b']->(Join)())
var sorted = [3, 1, 2]
-> sort()
assert_equal([1, 2, 3], sorted)
END END
CheckDefAndScriptSuccess(lines) CheckDefAndScriptSuccess(lines)
enddef enddef

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2964,
/**/ /**/
2963, 2963,
/**/ /**/

View File

@@ -4108,7 +4108,8 @@ compile_subscript(
// Also if a following line starts with ".x". // Also if a following line starts with ".x".
if (next != NULL && if (next != NULL &&
((next[0] == '-' && next[1] == '>' ((next[0] == '-' && next[1] == '>'
&& (next[2] == '{' || ASCII_ISALPHA(next[2]))) && (next[2] == '{'
|| ASCII_ISALPHA(*skipwhite(next + 2))))
|| (next[0] == '.' && eval_isdictc(next[1])))) || (next[0] == '.' && eval_isdictc(next[1]))))
{ {
next = next_line_from_context(cctx, TRUE); next = next_line_from_context(cctx, TRUE);