diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-04-10 06:07:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-10 06:07:29 +0800 |
commit | efb6640b2937dacef9eec1b2ace11b85b3b44a4a (patch) | |
tree | b57cf4a4a810cec76da5345f5e613bc1bb1f03ab | |
parent | f398552eb16c19c8410214ddcfa3980180818a58 (diff) | |
download | rneovim-efb6640b2937dacef9eec1b2ace11b85b3b44a4a.tar.gz rneovim-efb6640b2937dacef9eec1b2ace11b85b3b44a4a.tar.bz2 rneovim-efb6640b2937dacef9eec1b2ace11b85b3b44a4a.zip |
vim-patch:9.1.0287: Vim9: comment may be treated as heredoc start (#28257)
Problem: Vim9: comment may be treated as heredoc start.
(Ernie Rael)
Solution: Use skip_var_list() instead of find_name_end().
(zeertzjq)
fixes: vim/vim#14444
closes: vim/vim#14446
https://github.com/vim/vim/commit/9a91d2b72c20f213bbf77f27b7edd01e0e43d5e0
-rw-r--r-- | src/nvim/eval/userfunc.c | 10 | ||||
-rw-r--r-- | test/old/testdir/test_let.vim | 52 |
2 files changed, 59 insertions, 3 deletions
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 27f7f42739..72559fe9e0 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -2576,10 +2576,14 @@ void ex_function(exarg_T *eap) // and ":let [a, b] =<< [trim] EOF" arg = p; if (checkforcmd(&arg, "let", 2)) { - while (vim_strchr("$@&", *arg) != NULL) { - arg++; + int var_count = 0; + int semicolon = 0; + const char *argend = skip_var_list(arg, &var_count, &semicolon, true); + if (argend == NULL) { + // Invalid list assignment: skip to closing bracket. + argend = find_name_end(arg, NULL, NULL, FNE_INCL_BR); } - arg = skipwhite(find_name_end(arg, NULL, NULL, FNE_INCL_BR)); + arg = skipwhite(argend); if (arg[0] == '=' && arg[1] == '<' && arg[2] == '<') { p = skipwhite(arg + 3); while (true) { diff --git a/test/old/testdir/test_let.vim b/test/old/testdir/test_let.vim index a9cc8a14a4..d93d33b199 100644 --- a/test/old/testdir/test_let.vim +++ b/test/old/testdir/test_let.vim @@ -397,6 +397,42 @@ func Test_let_heredoc_fails() call assert_report('Caught exception: ' .. v:exception) endtry + try + let @- =<< 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 [a b c] =<< trim TEXT + change + insert + append + TEXT + call assert_report('No exception thrown') + catch /E475:/ + catch + call assert_report('Caught exception: ' .. v:exception) + endtry + + try + let [a; b; c] =<< trim TEXT + change + insert + append + TEXT + call assert_report('No exception thrown') + catch /E452:/ + catch + call assert_report('Caught exception: ' .. v:exception) + endtry + let text =<< trim END func WrongSyntax() let v =<< that there @@ -569,6 +605,22 @@ append END call assert_equal(['change', 'insert', 'append'], [a, b, c]) + " unpack assignment with semicolon + let [a; b] =<< END +change +insert +append +END + call assert_equal(['change', ['insert', 'append']], [a, b]) + + " unpack assignment with registers + let [@/, @", @-] =<< END +change +insert +append +END + call assert_equal(['change', 'insert', 'append'], [@/, @", @-]) + " curly braces name and list slice assignment let foo_3_bar = ['', '', ''] let foo_{1 + 2}_bar[ : ] =<< END |