From ecaa75b4cea329a3902b8565e028b32279b8322b Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 21 Jul 2019 23:04:21 +0200 Subject: [PATCH] patch 8.1.1729: heredoc with trim not properly handled in function Problem: Heredoc with trim not properly handled in function. Solution: Allow for missing indent. (FUJIWARA Takuya, closes #4713) --- src/testdir/test_let.vim | 9 +++++++++ src/userfunc.c | 37 +++++++++++++++++++++++-------------- src/version.c | 2 ++ 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/testdir/test_let.vim b/src/testdir/test_let.vim index 36900821b..3bb574894 100644 --- a/src/testdir/test_let.vim +++ b/src/testdir/test_let.vim @@ -188,6 +188,15 @@ func Test_let_heredoc_fails() call delete('XheredocBadMarker') endfunc +func Test_let_heredoc_trim_no_indent_marker() + let text =<< trim END + Text + with + indent +END + call assert_equal(['Text', 'with', 'indent'], text) +endfunc + " Test for the setting a variable using the heredoc syntax func Test_let_heredoc() let var1 =<< END diff --git a/src/userfunc.c b/src/userfunc.c index 0ff1bdb82..a07b1b397 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -2000,8 +2000,6 @@ ex_function(exarg_T *eap) int overwrite = FALSE; int indent; int nesting; - char_u *skip_until = NULL; - char_u *trimmed = NULL; dictitem_T *v; funcdict_T fudi; static int func_nr = 0; /* number for nameless function */ @@ -2012,6 +2010,9 @@ ex_function(exarg_T *eap) int do_concat = TRUE; linenr_T sourcing_lnum_off; linenr_T sourcing_lnum_top; + int is_heredoc = FALSE; + char_u *skip_until = NULL; + char_u *heredoc_trimmed = NULL; /* * ":function" without argument: list functions. @@ -2331,17 +2332,28 @@ ex_function(exarg_T *eap) if (skip_until != NULL) { - // Between ":append" and "." and between ":python <