aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/vars.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-29 08:12:32 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-04-29 09:20:52 +0800
commit4bcf8c15b3079ca72d6557890b50b35565fcd577 (patch)
treecc6a986bd307aec948e1f696f6755c5874e1b451 /src/nvim/eval/vars.c
parent291fd767e3979b25146c32115eacc3c2f8e1e517 (diff)
downloadrneovim-4bcf8c15b3079ca72d6557890b50b35565fcd577.tar.gz
rneovim-4bcf8c15b3079ca72d6557890b50b35565fcd577.tar.bz2
rneovim-4bcf8c15b3079ca72d6557890b50b35565fcd577.zip
vim-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 vim/vim#5916) https://github.com/vim/vim/commit/6c2b7b8055b96463f78abb70f58c4c6d6d4b9d55
Diffstat (limited to 'src/nvim/eval/vars.c')
-rw-r--r--src/nvim/eval/vars.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c
index 593ba9f6c3..dee3867a5a 100644
--- a/src/nvim/eval/vars.c
+++ b/src/nvim/eval/vars.c
@@ -155,14 +155,19 @@ char *eval_all_expr_in_str(char *str)
/// 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.
+///
/// @return a List with {lines} or NULL on failure.
-static list_T *heredoc_get(exarg_T *eap, char *cmd)
+list_T *heredoc_get(exarg_T *eap, char *cmd, bool script_get)
{
char *marker;
char *p;
int marker_indent_len = 0;
int text_indent_len = 0;
char *text_indent = NULL;
+ char dot[] = ".";
if (eap->getline == NULL) {
emsg(_("E991: cannot use =<< here"));
@@ -214,8 +219,14 @@ static list_T *heredoc_get(exarg_T *eap, char *cmd)
return NULL;
}
} 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;
+ }
}
char *theline = NULL;
@@ -353,7 +364,7 @@ void ex_let(exarg_T *eap)
if (expr[0] == '=' && expr[1] == '<' && expr[2] == '<') {
// HERE document
- list_T *l = heredoc_get(eap, expr + 3);
+ list_T *l = heredoc_get(eap, expr + 3, false);
if (l != NULL) {
tv_list_set_ret(&rettv, l);
if (!eap->skip) {