Patch 8.1.1729
Problem:    Heredoc with trim not properly handled in function.
Solution:   Allow for missing indent. (FUJIWARA Takuya, closes #4713)
Files:      src/userfunc.c, src/testdir/test_let.vim


*** ../vim-8.1.1728/src/userfunc.c      2019-07-14 15:48:35.245984506 +0200
--- src/userfunc.c      2019-07-21 22:59:41.480775845 +0200
***************
*** 2000,2007 ****
      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 */
--- 2000,2005 ----
***************
*** 2012,2017 ****
--- 2010,2018 ----
      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.
***************
*** 2331,2347 ****
  
        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)
            {
!               p = trimmed == NULL ? theline : theline + STRLEN(trimmed);
                if (STRCMP(p, skip_until) == 0)
                {
                    VIM_CLEAR(skip_until);
!                   VIM_CLEAR(trimmed);
                    do_concat = TRUE;
                }
            }
        }
--- 2332,2359 ----
  
        if (skip_until != NULL)
        {
!           // 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)
            {
!               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(heredoc_trimmed);
                    do_concat = TRUE;
+                   is_heredoc = FALSE;
                }
            }
        }
***************
*** 2453,2472 ****
                            && (!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));
                do_concat = FALSE;
            }
        }
  
--- 2465,2481 ----
                            && (!ASCII_ISALNUM(p[2])
                                || (p[2] == 't' && !ASCII_ISALNUM(p[3]))))))
            {
                p = skipwhite(arg + 3);
                if (STRNCMP(p, "trim", 4) == 0)
                {
                    // Ignore leading white space.
                    p = skipwhite(p + 4);
!                   heredoc_trimmed = vim_strnsave(theline,
                                          (int)(skipwhite(theline) - theline));
                }
!               skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p));
                do_concat = FALSE;
+               is_heredoc = TRUE;
            }
        }
  
*** ../vim-8.1.1728/src/testdir/test_let.vim    2019-07-21 14:14:22.796237688 
+0200
--- src/testdir/test_let.vim    2019-07-21 22:40:50.940116550 +0200
***************
*** 188,193 ****
--- 188,202 ----
    call delete('XheredocBadMarker')
  endfunc
  
+ func Test_let_heredoc_trim_no_indent_marker()
+   let text =<< trim END
+   Text
+   with
+   indent
+ END
+   call assert_equal(['Text', 'with', 'indent'], text)
+ endfunc
+ 
  " Test for the setting a variable using the heredoc syntax
  func Test_let_heredoc()
    let var1 =<< END
*** ../vim-8.1.1728/src/version.c       2019-07-21 21:51:56.027609355 +0200
--- src/version.c       2019-07-21 23:03:21.575426250 +0200
***************
*** 779,780 ****
--- 779,782 ----
  {   /* Add new patch number below this line */
+ /**/
+     1729,
  /**/

-- 
FATAL ERROR! SYSTEM HALTED! - Press any key to continue doing nothing.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201907212104.x6LL4uoA027372%40masaka.moolenaar.net.

Raspunde prin e-mail lui