From b5ac11139e5acff834df592c5a42e856e773221f Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Mon, 23 Sep 2019 19:46:45 +0200 Subject: vim-patch:8.1.1356: some text in heredoc assignment ends the text Problem: Some text in heredoc assignment ends the text. (Ozaki Kiichi) Solution: Recognize "let v =<<" and skip until the end. https://github.com/vim/vim/commit/8471e57026714c5a0faf89288ceef5231fb88d4f --- src/nvim/testdir/test_let.vim | 79 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 14 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_let.vim b/src/nvim/testdir/test_let.vim index 9887fb531e..43f35e2b9d 100644 --- a/src/nvim/testdir/test_let.vim +++ b/src/nvim/testdir/test_let.vim @@ -141,6 +141,27 @@ func Test_let_varg_fail() call s:set_varg8([0]) endfunction +func Test_let_heredoc_fails() + call assert_fails('let v =<< marker', 'E991:') + + let text =<< trim END + func WrongSyntax() + let v =<< that there + endfunc + END + call writefile(text, 'XheredocFail') + call assert_fails('source XheredocFail', 'E126:') + call delete('XheredocFail') + + let text =<< trim END + func MissingEnd() + let v =<< END + endfunc + END + call writefile(text, 'XheredocWrong') + call assert_fails('source XheredocWrong', 'E126:') + call delete('XheredocWrong') +endfunc " Test for the setting a variable using the heredoc syntax func Test_let_heredoc() @@ -170,12 +191,12 @@ END END call assert_equal(['vim', '', 'end', ' END', 'END '], var3) - let var1 =<< trim END - Line1 - Line2 - Line3 - END - END + let var1 =<< trim END + Line1 + Line2 + Line3 + END + END call assert_equal(['Line1', ' Line2', "\tLine3", ' END'], var1) let var1 =<< trim @@ -183,15 +204,45 @@ END . call assert_equal([' Line1'], var1) - call assert_fails('let v =<< marker', 'E991:') - call assert_fails('call WrongSyntax()', 'E488:') - call assert_fails('call MissingEnd()', 'E990:') + " ignore "endfunc" + let var1 =<< END +something endfunc +END + call assert_equal(['something', 'endfunc'], var1) -func WrongSyntax() - let fail =<< that there -endfunc + " ignore "endfunc" with trim + let var1 =<< trim END + something + endfunc + END + call assert_equal(['something', 'endfunc'], var1) + + " ignore "python << xx" + let var1 =<