vim-patch:8.1.2262: unpack assignment in function not recognized

Problem:    Unpack assignment in function not recognized.
Solution:   Skip over "[a, b]". (closes vim/vim#5051)
1e673b9eb6
This commit is contained in:
Jan Edmund Lazo
2019-11-06 22:32:54 -05:00
parent c3cb54b5ff
commit 3e2f7baf21
2 changed files with 31 additions and 14 deletions

View File

@@ -21742,24 +21742,33 @@ void ex_function(exarg_T *eap)
} }
// Check for ":let v =<< [trim] EOF" // Check for ":let v =<< [trim] EOF"
// and ":let [a, b] =<< [trim] EOF"
arg = skipwhite(skiptowhite(p)); arg = skipwhite(skiptowhite(p));
if (*arg == '[') {
arg = vim_strchr(arg, ']');
}
if (arg != NULL) {
arg = skipwhite(skiptowhite(arg)); arg = skipwhite(skiptowhite(arg));
if (arg[0] == '=' && arg[1] == '<' && arg[2] =='<' if (arg[0] == '='
&& ((p[0] == 'l' && p[1] == 'e' && arg[1] == '<'
&& arg[2] =='<'
&& (p[0] == 'l'
&& p[1] == 'e'
&& (!ASCII_ISALNUM(p[2]) && (!ASCII_ISALNUM(p[2])
|| (p[2] == 't' && !ASCII_ISALNUM(p[3])))))) { || (p[2] == 't' && !ASCII_ISALNUM(p[3]))))) {
p = skipwhite(arg + 3); p = skipwhite(arg + 3);
if (STRNCMP(p, "trim", 4) == 0) { if (STRNCMP(p, "trim", 4) == 0) {
// Ignore leading white space. // Ignore leading white space.
p = skipwhite(p + 4); p = skipwhite(p + 4);
heredoc_trimmed = vim_strnsave(theline, heredoc_trimmed =
(int)(skipwhite(theline) - theline)); vim_strnsave(theline, (int)(skipwhite(theline) - theline));
} }
skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p)); skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p));
do_concat = false; do_concat = false;
is_heredoc = true; is_heredoc = true;
} }
} }
}
/* Add the line to the function. */ /* Add the line to the function. */
ga_grow(&newlines, 1 + sourcing_lnum_off); ga_grow(&newlines, 1 + sourcing_lnum_off);

View File

@@ -289,4 +289,12 @@ E
END END
endif endif
call assert_equal([], check) call assert_equal([], check)
" unpack assignment
let [a, b, c] =<< END
x
\y
z
END
call assert_equal([' x', ' \y', ' z'], [a, b, c])
endfunc endfunc