Mercurial > vim
diff src/evalvars.c @ 20045:04ef2ccf2519 v8.2.0578
patch 8.2.0578: heredoc for interfaces does not support "trim"
Commit: https://github.com/vim/vim/commit/6c2b7b8055b96463f78abb70f58c4c6d6d4b9d55
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Apr 14 20:15:49 2020 +0200
patch 8.2.0578: heredoc for interfaces does not support "trim"
Problem: Heredoc for interfaces does not support "trim".
Solution: Update the script heredoc support to be same as the :let command.
(Yegappan Lakshmanan, closes #5916)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 14 Apr 2020 20:30:05 +0200 |
parents | 12fa79cac39b |
children | a64c16ff98b8 |
line wrap: on
line diff
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -541,10 +541,15 @@ list_script_vars(int *first) * The {marker} is a string. If the optional 'trim' word is supplied before the * marker, then the leading indentation before the lines (matching the * indentation in the 'cmd' line) is stripped. + * + * When getting lines for an embedded script (e.g. python, lua, perl, ruby, + * tcl, mzscheme), script_get is set to TRUE. In this case, if the marker is + * missing, then '.' is accepted as a marker. + * * Returns a List with {lines} or NULL. */ list_T * -heredoc_get(exarg_T *eap, char_u *cmd) +heredoc_get(exarg_T *eap, char_u *cmd, int script_get) { char_u *theline; char_u *marker; @@ -553,6 +558,7 @@ heredoc_get(exarg_T *eap, char_u *cmd) int marker_indent_len = 0; int text_indent_len = 0; char_u *text_indent = NULL; + char_u dot[] = "."; if (eap->getline == NULL) { @@ -598,8 +604,15 @@ heredoc_get(exarg_T *eap, char_u *cmd) } else { - emsg(_("E172: Missing marker")); - return NULL; + // When getting lines for an embedded script, if the marker is missing, + // accept '.' as the marker. + if (script_get) + marker = dot; + else + { + emsg(_("E172: Missing marker")); + return NULL; + } } l = list_alloc(); @@ -746,7 +759,7 @@ ex_let_const(exarg_T *eap, int is_const) list_T *l; // HERE document - l = heredoc_get(eap, expr + 3); + l = heredoc_get(eap, expr + 3, FALSE); if (l != NULL) { rettv_list_set(&rettv, l);