forked from aniani/vim
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Problem: Vim9: cannot use heredoc in :def function for :python, :lua, etc. Solution: Concatenate the heredoc lines and pass them in the ISN_EXEC_SPLIT instruction.
This commit is contained in:
@@ -1213,6 +1213,37 @@ get_script_svar(scriptref_T *sref, ectx_T *ectx)
|
||||
return sv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function passed to do_cmdline() for splitting a script joined by NL
|
||||
* characters.
|
||||
*/
|
||||
static char_u *
|
||||
get_split_sourceline(
|
||||
int c UNUSED,
|
||||
void *cookie,
|
||||
int indent UNUSED,
|
||||
getline_opt_T options UNUSED)
|
||||
{
|
||||
source_cookie_T *sp = (source_cookie_T *)cookie;
|
||||
char_u *p;
|
||||
char_u *line;
|
||||
|
||||
if (*sp->nextline == NUL)
|
||||
return NULL;
|
||||
p = vim_strchr(sp->nextline, '\n');
|
||||
if (p == NULL)
|
||||
{
|
||||
line = vim_strsave(sp->nextline);
|
||||
sp->nextline += STRLEN(sp->nextline);
|
||||
}
|
||||
else
|
||||
{
|
||||
line = vim_strnsave(sp->nextline, p - sp->nextline);
|
||||
sp->nextline = p + 1;
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute a function by "name".
|
||||
* This can be a builtin function, user function or a funcref.
|
||||
@@ -1425,6 +1456,24 @@ exec_instructions(ectx_T *ectx)
|
||||
}
|
||||
break;
|
||||
|
||||
// execute Ex command line split at NL characters.
|
||||
case ISN_EXEC_SPLIT:
|
||||
{
|
||||
source_cookie_T cookie;
|
||||
|
||||
SOURCING_LNUM = iptr->isn_lnum;
|
||||
CLEAR_FIELD(cookie);
|
||||
cookie.sourcing_lnum = iptr->isn_lnum - 1;
|
||||
cookie.nextline = iptr->isn_arg.string;
|
||||
if (do_cmdline(get_split_sourceline(0, &cookie, 0, 0),
|
||||
get_split_sourceline, &cookie,
|
||||
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED)
|
||||
== FAIL
|
||||
|| did_emsg)
|
||||
goto on_error;
|
||||
}
|
||||
break;
|
||||
|
||||
// Evaluate an expression with legacy syntax, push it onto the
|
||||
// stack.
|
||||
case ISN_LEGACY_EVAL:
|
||||
@@ -4536,6 +4585,9 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc)
|
||||
case ISN_EXEC:
|
||||
smsg("%s%4d EXEC %s", pfx, current, iptr->isn_arg.string);
|
||||
break;
|
||||
case ISN_EXEC_SPLIT:
|
||||
smsg("%s%4d EXEC_SPLIT %s", pfx, current, iptr->isn_arg.string);
|
||||
break;
|
||||
case ISN_LEGACY_EVAL:
|
||||
smsg("%s%4d EVAL legacy %s", pfx, current,
|
||||
iptr->isn_arg.string);
|
||||
|
Reference in New Issue
Block a user