diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-05-03 00:05:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-03 00:05:46 +0800 |
commit | bff3f4fa8bbadf7494bcf3098eee8da39cc2c436 (patch) | |
tree | d6c2d32147af87f7ac7146c39d2e2c7f68afd88c | |
parent | f186224dfcf86678b6e5ee126d6b9a393f02f634 (diff) | |
download | rneovim-bff3f4fa8bbadf7494bcf3098eee8da39cc2c436.tar.gz rneovim-bff3f4fa8bbadf7494bcf3098eee8da39cc2c436.tar.bz2 rneovim-bff3f4fa8bbadf7494bcf3098eee8da39cc2c436.zip |
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)
https://github.com/vim/vim/commit/a93d9cdc74f70ca2c85781496ffae4ca738fcd88
-rw-r--r-- | src/nvim/eval/userfunc.c | 20 | ||||
-rw-r--r-- | test/old/testdir/test_let.vim | 64 |
2 files changed, 70 insertions, 14 deletions
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 1f5a6eaec4..bfda2c4b9b 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -2587,19 +2587,13 @@ void ex_function(exarg_T *eap) // Check for ":let v =<< [trim] EOF" // and ":let [a, b] =<< [trim] EOF" - arg = skipwhite(skiptowhite(p)); - if (*arg == '[') { - arg = vim_strchr(arg, ']'); - } - if (arg != NULL) { - arg = skipwhite(skiptowhite(arg)); - if (arg[0] == '=' - && arg[1] == '<' - && arg[2] == '<' - && (p[0] == 'l' - && p[1] == 'e' - && (!ASCII_ISALNUM(p[2]) - || (p[2] == 't' && !ASCII_ISALNUM(p[3]))))) { + arg = p; + if (checkforcmd(&arg, "let", 2)) { + while (vim_strchr("$@&", *arg) != NULL) { + arg++; + } + arg = skipwhite(find_name_end(arg, NULL, NULL, FNE_INCL_BR)); + if (arg[0] == '=' && arg[1] == '<' && arg[2] == '<') { p = skipwhite(arg + 3); while (true) { if (strncmp(p, "trim", 4) == 0) { diff --git a/test/old/testdir/test_let.vim b/test/old/testdir/test_let.vim index 0d84164274..bf119bdeab 100644 --- a/test/old/testdir/test_let.vim +++ b/test/old/testdir/test_let.vim @@ -338,7 +338,43 @@ func Test_let_heredoc_fails() call assert_report('No exception thrown') catch /E488:/ 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 let text =<< trim END @@ -504,6 +540,32 @@ E z END 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 " Test for evaluating Vim expressions in a heredoc using {expr} |