aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorJurica Bradaric <jbradaric@gmail.com>2019-09-23 19:46:45 +0200
committerJurica Bradaric <jbradaric@gmail.com>2019-10-07 14:14:13 +0200
commitb5ac11139e5acff834df592c5a42e856e773221f (patch)
treefc22f9c486c88301696fbdaa72fb9e42716b143b /src/nvim/eval.c
parentb1ada8ec2159fbc69b58cc40eb62a4e76edd8d45 (diff)
downloadrneovim-b5ac11139e5acff834df592c5a42e856e773221f.tar.gz
rneovim-b5ac11139e5acff834df592c5a42e856e773221f.tar.bz2
rneovim-b5ac11139e5acff834df592c5a42e856e773221f.zip
vim-patch:8.1.1356: some text in heredoc assignment ends the text
Problem: Some text in heredoc assignment ends the text. (Ozaki Kiichi) Solution: Recognize "let v =<<" and skip until the end. https://github.com/vim/vim/commit/8471e57026714c5a0faf89288ceef5231fb88d4f
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 9b12ca1e12..6d706939a1 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -21269,6 +21269,7 @@ void ex_function(exarg_T *eap)
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 */
@@ -21572,10 +21573,14 @@ void ex_function(exarg_T *eap)
sourcing_lnum_off = 0;
if (skip_until != NULL) {
- /* between ":append" and "." and between ":python <<EOF" and "EOF"
- * don't check for ":endfunc". */
- if (STRCMP(theline, skip_until) == 0) {
- XFREE_CLEAR(skip_until);
+ // Between ":append" and "." and between ":python <<EOF" and "EOF"
+ // don't check for ":endfunc".
+ if (trimmed == NULL || STRNCMP(theline, trimmed, STRLEN(trimmed)) == 0) {
+ p = trimmed == NULL ? theline : theline + STRLEN(trimmed);
+ if (STRCMP(p, skip_until) == 0) {
+ XFREE_CLEAR(skip_until);
+ XFREE_CLEAR(trimmed);
+ }
}
} else {
/* skip ':' and blanks*/
@@ -21674,6 +21679,27 @@ void ex_function(exarg_T *eap)
else
skip_until = vim_strsave(p);
}
+
+ // Check for ":let v =<< [trim] EOF"
+ arg = skipwhite(skiptowhite(p));
+ arg = skipwhite(skiptowhite(arg));
+ if (arg[0] == '=' && arg[1] == '<' && arg[2] =='<'
+ && ((p[0] == 'l' && p[1] == 'e'
+ && (!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, (int)(skipwhite(theline) - theline));
+ }
+ if (*p == NUL) {
+ skip_until = vim_strsave((char_u *)".");
+ } else {
+ skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p));
+ }
+ }
}
/* Add the line to the function. */