Patch 8.2.2242
Problem:    Vim9: line continuation with bar does not work at script level.
Solution:   Check for Vim9 script.
Files:      src/structs.h, src/ex_docmd.c, src/userfunc.c, src/scriptfile.c,
            src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.2241/src/structs.h       2020-12-28 20:53:17.499051882 +0100
--- src/structs.h       2020-12-29 11:06:28.314099101 +0100
***************
*** 1565,1572 ****
  // type of getline() last argument
  typedef enum {
      GETLINE_NONE,         // do not concatenate any lines
!     GETLINE_CONCAT_CONT,    // concatenate continuation lines in Vim9 script
!     GETLINE_CONCAT_CONTDEF, // concatenate continuation lines always
      GETLINE_CONCAT_ALL            // concatenate continuation and Vim9 # 
comment lines
  } getline_opt_T;
  
--- 1565,1572 ----
  // type of getline() last argument
  typedef enum {
      GETLINE_NONE,         // do not concatenate any lines
!     GETLINE_CONCAT_CONT,    // concatenate continuation lines with backslash
!     GETLINE_CONCAT_CONTBAR, // concatenate continuation lines with \ and |
      GETLINE_CONCAT_ALL            // concatenate continuation and Vim9 # 
comment lines
  } getline_opt_T;
  
*** ../vim-8.2.2241/src/ex_docmd.c      2020-12-28 18:25:56.796886014 +0100
--- src/ex_docmd.c      2020-12-29 11:07:49.317875897 +0100
***************
*** 889,895 ****
  #else
                    0
  #endif
!                   , TRUE)) == NULL)
            {
                // Don't call wait_return for aborted command line.  The NULL
                // returned for the end of a sourced file or executed function
--- 889,896 ----
  #else
                    0
  #endif
!                   , in_vim9script() ? GETLINE_CONCAT_CONTBAR
!                                              : GETLINE_CONCAT_CONT)) == NULL)
            {
                // Don't call wait_return for aborted command line.  The NULL
                // returned for the end of a sourced file or executed function
*** ../vim-8.2.2241/src/userfunc.c      2020-12-28 20:53:17.499051882 +0100
--- src/userfunc.c      2020-12-29 11:06:11.658144086 +0100
***************
*** 3292,3298 ****
      nesting = 0;
      nesting_def[nesting] = (eap->cmdidx == CMD_def);
      getline_options = eap->cmdidx == CMD_def
!                               ? GETLINE_CONCAT_CONTDEF : GETLINE_CONCAT_CONT;
      for (;;)
      {
        if (KeyTyped)
--- 3292,3298 ----
      nesting = 0;
      nesting_def[nesting] = (eap->cmdidx == CMD_def);
      getline_options = eap->cmdidx == CMD_def
!                               ? GETLINE_CONCAT_CONTBAR : GETLINE_CONCAT_CONT;
      for (;;)
      {
        if (KeyTyped)
***************
*** 3368,3374 ****
                    VIM_CLEAR(skip_until);
                    VIM_CLEAR(heredoc_trimmed);
                    getline_options = eap->cmdidx == CMD_def
!                               ? GETLINE_CONCAT_CONTDEF : GETLINE_CONCAT_CONT;
                    is_heredoc = FALSE;
                }
            }
--- 3368,3374 ----
                    VIM_CLEAR(skip_until);
                    VIM_CLEAR(heredoc_trimmed);
                    getline_options = eap->cmdidx == CMD_def
!                               ? GETLINE_CONCAT_CONTBAR : GETLINE_CONCAT_CONT;
                    is_heredoc = FALSE;
                }
            }
*** ../vim-8.2.2241/src/scriptfile.c    2020-12-28 20:53:17.495051906 +0100
--- src/scriptfile.c    2020-12-29 11:13:14.120925197 +0100
***************
*** 1741,1748 ****
      char_u            *p;
      int                       do_vim9_all = in_vim9script()
                                              && options == GETLINE_CONCAT_ALL;
!     int                       do_vim9_cont = do_vim9_all
!                                        || options == GETLINE_CONCAT_CONTDEF;
  
  #ifdef FEAT_EVAL
      // If breakpoints have been added/deleted need to check for it.
--- 1741,1748 ----
      char_u            *p;
      int                       do_vim9_all = in_vim9script()
                                              && options == GETLINE_CONCAT_ALL;
!     int                       do_bar_cont = do_vim9_all
!                                        || options == GETLINE_CONCAT_CONTBAR;
  
  #ifdef FEAT_EVAL
      // If breakpoints have been added/deleted need to check for it.
***************
*** 1797,1803 ****
                              || (p[0] == '"' && p[1] == '\\' && p[2] == ' ')
                              || (do_vim9_all && (*p == NUL
                                                     || vim9_comment_start(p)))
!                             || (do_vim9_cont && p[0] == '|' && p[1] != '|')))
        {
            garray_T    ga;
  
--- 1797,1803 ----
                              || (p[0] == '"' && p[1] == '\\' && p[2] == ' ')
                              || (do_vim9_all && (*p == NUL
                                                     || vim9_comment_start(p)))
!                             || (do_bar_cont && p[0] == '|' && p[1] != '|')))
        {
            garray_T    ga;
  
***************
*** 1817,1823 ****
                if (sp->nextline == NULL)
                    break;
                p = skipwhite(sp->nextline);
!               if (*p == '\\' || (do_vim9_cont && p[0] == '|' && p[1] != '|'))
                {
                    // Adjust the growsize to the current length to speed up
                    // concatenating many lines.
--- 1817,1823 ----
                if (sp->nextline == NULL)
                    break;
                p = skipwhite(sp->nextline);
!               if (*p == '\\' || (do_bar_cont && p[0] == '|' && p[1] != '|'))
                {
                    // Adjust the growsize to the current length to speed up
                    // concatenating many lines.
*** ../vim-8.2.2241/src/testdir/test_vim9_cmd.vim       2020-12-28 
20:53:17.499051882 +0100
--- src/testdir/test_vim9_cmd.vim       2020-12-29 10:58:52.255275280 +0100
***************
*** 536,541 ****
--- 536,572 ----
    quit!
  enddef
  
+ def Test_bar_line_continuation()
+   var lines =<< trim END
+       au BufNewFile Xfile g:readFile = 1
+           | g:readExtra = 2
+       g:readFile = 0
+       g:readExtra = 0
+       edit Xfile
+       assert_equal(1, g:readFile)
+       assert_equal(2, g:readExtra)
+       bwipe!
+       au! BufNewFile
+ 
+       au BufNewFile Xfile g:readFile = 1
+           | g:readExtra = 2
+           | g:readMore = 3
+       g:readFile = 0
+       g:readExtra = 0
+       g:readMore = 0
+       edit Xfile
+       assert_equal(1, g:readFile)
+       assert_equal(2, g:readExtra)
+       assert_equal(3, g:readMore)
+       bwipe!
+       au! BufNewFile
+       unlet g:readFile
+       unlet g:readExtra
+       unlet g:readMore
+   END
+   CheckDefAndScriptSuccess(lines)
+ enddef
+ 
  def Test_command_modifier_other()
    new Xsomefile
    setline(1, 'changed')
***************
*** 548,580 ****
    bwipe!
  
    au BufNewFile Xfile g:readFile = 1
-       | g:readExtra = 2
    g:readFile = 0
-   g:readExtra = 0
    edit Xfile
    assert_equal(1, g:readFile)
-   assert_equal(2, g:readExtra)
    bwipe!
    g:readFile = 0
    noautocmd edit Xfile
    assert_equal(0, g:readFile)
    au! BufNewFile
- 
-   au BufNewFile Xfile g:readFile = 1
-       | g:readExtra = 2
-       | g:readMore = 3
-   g:readFile = 0
-   g:readExtra = 0
-   g:readMore = 0
-   edit Xfile
-   assert_equal(1, g:readFile)
-   assert_equal(2, g:readExtra)
-   assert_equal(3, g:readMore)
-   bwipe!
-   au! BufNewFile
    unlet g:readFile
-   unlet g:readExtra
-   unlet g:readMore
  
    noswapfile edit XnoSwap
    assert_equal(0, &l:swapfile)
--- 579,593 ----
*** ../vim-8.2.2241/src/version.c       2020-12-28 21:36:52.508817422 +0100
--- src/version.c       2020-12-29 11:14:22.820715697 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2242,
  /**/

-- 
Seen it all, done it all, can't remember most of it.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202012291015.0BTAFTu1586776%40masaka.moolenaar.net.

Raspunde prin e-mail lui