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 */
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.
if (skip_until != NULL)
{
- // Between ":append" and "." and between ":python <<EOF" and "EOF"
- // don't check for ":endfunc".
- if (trimmed == NULL
- || STRNCMP(theline, trimmed, STRLEN(trimmed)) == 0)
+ // Don't check for ":endfunc" between
+ // * ":append" and "."
+ // * ":python <<EOF" and "EOF"
+ // * ":let {var-name} =<< [trim] {marker}" and "{marker}"
+ if (heredoc_trimmed == NULL
+ || (is_heredoc && skipwhite(theline) == theline)
+ || STRNCMP(theline, heredoc_trimmed,
+ STRLEN(heredoc_trimmed)) == 0)
{
- p = trimmed == NULL ? theline : theline + STRLEN(trimmed);
+ if (heredoc_trimmed == NULL)
+ p = theline;
+ else if (is_heredoc)
+ p = skipwhite(theline) == theline
+ ? theline : theline + STRLEN(heredoc_trimmed);
+ else
+ p = theline + STRLEN(heredoc_trimmed);
if (STRCMP(p, skip_until) == 0)
{
VIM_CLEAR(skip_until);
- VIM_CLEAR(trimmed);
+ VIM_CLEAR(heredoc_trimmed);
do_concat = TRUE;
+ is_heredoc = FALSE;
}
}
}
&& (!ASCII_ISALNUM(p[2])
|| (p[2] == 't' && !ASCII_ISALNUM(p[3]))))))
{
- // ":let v =<<" continues until a dot
p = skipwhite(arg + 3);
if (STRNCMP(p, "trim", 4) == 0)
{
// Ignore leading white space.
p = skipwhite(p + 4);
- trimmed = vim_strnsave(theline,
+ heredoc_trimmed = vim_strnsave(theline,
(int)(skipwhite(theline) - theline));
}
- if (*p == NUL)
- skip_until = vim_strsave((char_u *)".");
- else
- skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p));
+ skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p));
do_concat = FALSE;
+ is_heredoc = TRUE;
}
}