From 617a3851426434bc22d82fe7574ba8f0455c0dcd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 Apr 2024 05:55:51 +0800 Subject: vim-patch:9.1.0312: heredocs are not supported for :commands Problem: heredocs are not supported for :commands (balki) Solution: Add heredoc support (Yegappan Lakshmanan) fixes: vim/vim#14491 closes: vim/vim#14528 https://github.com/vim/vim/commit/e74cad3321ce1dcefc1fc64f617511275b6cd930 Co-authored-by: Yegappan Lakshmanan --- test/old/testdir/test_let.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/old/testdir') diff --git a/test/old/testdir/test_let.vim b/test/old/testdir/test_let.vim index 655c177385..56b880f3b0 100644 --- a/test/old/testdir/test_let.vim +++ b/test/old/testdir/test_let.vim @@ -713,6 +713,20 @@ END LINES call CheckScriptFailure(lines, 'E15:') + " Test for using heredoc in a single string using execute() + call assert_equal(["['one', 'two']"], + \ execute("let x =<< trim END\n one\n two\nEND\necho x")->split("\n")) + call assert_equal(["[' one', ' two']"], + \ execute("let x =<< END\n one\n two\nEND\necho x")->split("\n")) + let cmd = 'execute("let x =<< END\n one\n two\necho x")' + call assert_fails(cmd, "E990: Missing end marker 'END'") + let cmd = 'execute("let x =<<\n one\n two\necho x")' + call assert_fails(cmd, "E990: Missing end marker ''") + let cmd = 'execute("let x =<< trim\n one\n two\necho x")' + call assert_fails(cmd, "E221: Marker cannot start with lower case letter") + let cmd = 'execute("let x =<< eval END\n one\n two{y}\nEND\necho x")' + call assert_fails(cmd, 'E121: Undefined variable: y') + " skipped heredoc if 0 let msg =<< trim eval END -- cgit From e81fe387d6291e5643a97a61e6d05b48aaeab2a1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 14 Apr 2024 05:03:49 +0800 Subject: vim-patch:9.1.0313: Crash when using heredoc with comment in command block Problem: Crash when using heredoc with comment in command block. Solution: Handle a newline more like the end of the line, fix coverity warning (zeertzjq). closes: vim/vim#14535 https://github.com/vim/vim/commit/1f5175d9af3d3f37e19f23e0e6f84caec47390f2 --- test/old/testdir/test_let.vim | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'test/old/testdir') diff --git a/test/old/testdir/test_let.vim b/test/old/testdir/test_let.vim index 56b880f3b0..da4334833b 100644 --- a/test/old/testdir/test_let.vim +++ b/test/old/testdir/test_let.vim @@ -542,6 +542,13 @@ END XX call assert_equal(['Line1'], var1) + let var1 =<< trim XX " comment + Line1 + Line2 + Line3 + XX + call assert_equal(['Line1', ' Line2', 'Line3'], var1) + " ignore "endfunc" let var1 =<< END something @@ -714,15 +721,27 @@ END call CheckScriptFailure(lines, 'E15:') " Test for using heredoc in a single string using execute() - call assert_equal(["['one', 'two']"], - \ execute("let x =<< trim END\n one\n two\nEND\necho x")->split("\n")) - call assert_equal(["[' one', ' two']"], - \ execute("let x =<< END\n one\n two\nEND\necho x")->split("\n")) + call assert_equal("\n['one', 'two']", + \ execute("let x =<< trim END\n one\n two\nEND\necho x")) + call assert_equal("\n['one', ' two']", + \ execute("let x =<< trim END\n one\n two\nEND\necho x")) + call assert_equal("\n['one', 'two']", + \ execute(" let x =<< trim END\n one\n two\n END\necho x")) + call assert_equal("\n['one', ' two']", + \ execute(" let x =<< trim END\n one\n two\n END\necho x")) + call assert_equal("\n[' one', ' two']", + \ execute("let x =<< END\n one\n two\nEND\necho x")) + call assert_equal("\n['one', 'two']", + \ execute("let x =<< END\none\ntwo\nEND\necho x")) + call assert_equal("\n['one', 'two']", + \ execute("let x =<< END \" comment\none\ntwo\nEND\necho x")) let cmd = 'execute("let x =<< END\n one\n two\necho x")' call assert_fails(cmd, "E990: Missing end marker 'END'") let cmd = 'execute("let x =<<\n one\n two\necho x")' - call assert_fails(cmd, "E990: Missing end marker ''") + call assert_fails(cmd, "E172: Missing marker") let cmd = 'execute("let x =<< trim\n one\n two\necho x")' + call assert_fails(cmd, "E172: Missing marker") + let cmd = 'execute("let x =<< end\n one\n two\nend\necho x")' call assert_fails(cmd, "E221: Marker cannot start with lower case letter") let cmd = 'execute("let x =<< eval END\n one\n two{y}\nEND\necho x")' call assert_fails(cmd, 'E121: Undefined variable: y') -- cgit