mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.1505: error when heredoc content looks like heredoc (#23446)
Problem: Error when heredoc content looks like heredoc.
Solution: Handle curly expressions. (closes vim/vim#12325)
a93d9cdc74
This commit is contained in:
parent
f186224dfc
commit
bff3f4fa8b
@ -2587,19 +2587,13 @@ void ex_function(exarg_T *eap)
|
|||||||
|
|
||||||
// Check for ":let v =<< [trim] EOF"
|
// Check for ":let v =<< [trim] EOF"
|
||||||
// and ":let [a, b] =<< [trim] EOF"
|
// and ":let [a, b] =<< [trim] EOF"
|
||||||
arg = skipwhite(skiptowhite(p));
|
arg = p;
|
||||||
if (*arg == '[') {
|
if (checkforcmd(&arg, "let", 2)) {
|
||||||
arg = vim_strchr(arg, ']');
|
while (vim_strchr("$@&", *arg) != NULL) {
|
||||||
}
|
arg++;
|
||||||
if (arg != NULL) {
|
}
|
||||||
arg = skipwhite(skiptowhite(arg));
|
arg = skipwhite(find_name_end(arg, NULL, NULL, FNE_INCL_BR));
|
||||||
if (arg[0] == '='
|
if (arg[0] == '=' && arg[1] == '<' && arg[2] == '<') {
|
||||||
&& arg[1] == '<'
|
|
||||||
&& arg[2] == '<'
|
|
||||||
&& (p[0] == 'l'
|
|
||||||
&& p[1] == 'e'
|
|
||||||
&& (!ASCII_ISALNUM(p[2])
|
|
||||||
|| (p[2] == 't' && !ASCII_ISALNUM(p[3]))))) {
|
|
||||||
p = skipwhite(arg + 3);
|
p = skipwhite(arg + 3);
|
||||||
while (true) {
|
while (true) {
|
||||||
if (strncmp(p, "trim", 4) == 0) {
|
if (strncmp(p, "trim", 4) == 0) {
|
||||||
|
@ -338,7 +338,43 @@ func Test_let_heredoc_fails()
|
|||||||
call assert_report('No exception thrown')
|
call assert_report('No exception thrown')
|
||||||
catch /E488:/
|
catch /E488:/
|
||||||
catch
|
catch
|
||||||
call assert_report("Caught exception: " .. v:exception)
|
call assert_report('Caught exception: ' .. v:exception)
|
||||||
|
endtry
|
||||||
|
|
||||||
|
try
|
||||||
|
let &commentstring =<< trim TEXT
|
||||||
|
change
|
||||||
|
insert
|
||||||
|
append
|
||||||
|
TEXT
|
||||||
|
call assert_report('No exception thrown')
|
||||||
|
catch /E730:/
|
||||||
|
catch
|
||||||
|
call assert_report('Caught exception: ' .. v:exception)
|
||||||
|
endtry
|
||||||
|
|
||||||
|
try
|
||||||
|
let $SOME_ENV_VAR =<< trim TEXT
|
||||||
|
change
|
||||||
|
insert
|
||||||
|
append
|
||||||
|
TEXT
|
||||||
|
call assert_report('No exception thrown')
|
||||||
|
catch /E730:/
|
||||||
|
catch
|
||||||
|
call assert_report('Caught exception: ' .. v:exception)
|
||||||
|
endtry
|
||||||
|
|
||||||
|
try
|
||||||
|
let @r =<< trim TEXT
|
||||||
|
change
|
||||||
|
insert
|
||||||
|
append
|
||||||
|
TEXT
|
||||||
|
call assert_report('No exception thrown')
|
||||||
|
catch /E730:/
|
||||||
|
catch
|
||||||
|
call assert_report('Caught exception: ' .. v:exception)
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
let text =<< trim END
|
let text =<< trim END
|
||||||
@ -504,6 +540,32 @@ E
|
|||||||
z
|
z
|
||||||
END
|
END
|
||||||
call assert_equal([' x', ' \y', ' z'], [a, b, c])
|
call assert_equal([' x', ' \y', ' z'], [a, b, c])
|
||||||
|
|
||||||
|
" unpack assignment without whitespace
|
||||||
|
let[a,b,c]=<<END
|
||||||
|
change
|
||||||
|
insert
|
||||||
|
append
|
||||||
|
END
|
||||||
|
call assert_equal(['change', 'insert', 'append'], [a, b, c])
|
||||||
|
|
||||||
|
" curly braces name and list slice assignment
|
||||||
|
let foo_3_bar = ['', '', '']
|
||||||
|
let foo_{1 + 2}_bar[ : ] =<< END
|
||||||
|
change
|
||||||
|
insert
|
||||||
|
append
|
||||||
|
END
|
||||||
|
call assert_equal(['change', 'insert', 'append'], foo_3_bar)
|
||||||
|
|
||||||
|
" dictionary key containing brackets and spaces
|
||||||
|
let d = {'abc] 123': 'baz'}
|
||||||
|
let d[d['abc] 123'] .. '{'] =<< END
|
||||||
|
change
|
||||||
|
insert
|
||||||
|
append
|
||||||
|
END
|
||||||
|
call assert_equal(['change', 'insert', 'append'], d['baz{'])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for evaluating Vim expressions in a heredoc using {expr}
|
" Test for evaluating Vim expressions in a heredoc using {expr}
|
||||||
|
Loading…
Reference in New Issue
Block a user