Patch 8.2.4615
Problem:    Mapping with escaped bar does not work in :def function. (Sergey
            Vlasov)
Solution:   Do not remove the backslash. (closes #10002)
Files:      src/ex_docmd.c, src/proto/ex_docmd.pro, src/syntax.c,
            src/vim9cmds.c, src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.4614/src/ex_docmd.c      2022-03-21 19:45:13.200420997 +0000
--- src/ex_docmd.c      2022-03-23 19:29:20.070551299 +0000
***************
*** 2275,2281 ****
       */
      if ((ea.argt & EX_TRLBAR) && !ea.usefilter)
      {
!       separate_nextcmd(&ea);
      }
      else if (ea.cmdidx == CMD_bang
            || ea.cmdidx == CMD_terminal
--- 2275,2281 ----
       */
      if ((ea.argt & EX_TRLBAR) && !ea.usefilter)
      {
!       separate_nextcmd(&ea, FALSE);
      }
      else if (ea.cmdidx == CMD_bang
            || ea.cmdidx == CMD_terminal
***************
*** 5081,5089 ****
  
  /*
   * Check for '|' to separate commands and '"' to start comments.
   */
      void
! separate_nextcmd(exarg_T *eap)
  {
      char_u    *p;
  
--- 5081,5090 ----
  
  /*
   * Check for '|' to separate commands and '"' to start comments.
+  * If "keep_backslash" is TRUE do not remove any backslash.
   */
      void
! separate_nextcmd(exarg_T *eap, int keep_backslash)
  {
      char_u    *p;
  
***************
*** 5097,5103 ****
      {
        if (*p == Ctrl_V)
        {
!           if (eap->argt & (EX_CTRLV | EX_XFILE))
                ++p;            // skip CTRL-V and next char
            else
                                // remove CTRL-V and skip next char
--- 5098,5104 ----
      {
        if (*p == Ctrl_V)
        {
!           if ((eap->argt & (EX_CTRLV | EX_XFILE)) || keep_backslash)
                ++p;            // skip CTRL-V and next char
            else
                                // remove CTRL-V and skip next char
***************
*** 5144,5151 ****
            if ((vim_strchr(p_cpo, CPO_BAR) == NULL
                              || !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\')
            {
!               STRMOVE(p - 1, p);      // remove the '\'
!               --p;
            }
            else
            {
--- 5145,5155 ----
            if ((vim_strchr(p_cpo, CPO_BAR) == NULL
                              || !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\')
            {
!               if (!keep_backslash)
!               {
!                   STRMOVE(p - 1, p);  // remove the '\'
!                   --p;
!               }
            }
            else
            {
*** ../vim-8.2.4614/src/proto/ex_docmd.pro      2022-02-09 12:58:16.498258787 
+0000
--- src/proto/ex_docmd.pro      2022-03-23 19:22:04.230663061 +0000
***************
*** 26,32 ****
  char_u *skip_range(char_u *cmd_start, int skip_star, int *ctx);
  void ex_ni(exarg_T *eap);
  int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp);
! void separate_nextcmd(exarg_T *eap);
  char_u *skip_cmd_arg(char_u *p, int rembs);
  int get_bad_opt(char_u *p, exarg_T *eap);
  int ends_excmd(int c);
--- 26,32 ----
  char_u *skip_range(char_u *cmd_start, int skip_star, int *ctx);
  void ex_ni(exarg_T *eap);
  int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp);
! void separate_nextcmd(exarg_T *eap, int keep_backslash);
  char_u *skip_cmd_arg(char_u *p, int rembs);
  int get_bad_opt(char_u *p, exarg_T *eap);
  int ends_excmd(int c);
*** ../vim-8.2.4614/src/syntax.c        2022-02-16 19:24:03.630162410 +0000
--- src/syntax.c        2022-03-23 19:22:16.554659995 +0000
***************
*** 4764,4770 ****
       * filename to include.
       */
      eap->argt |= (EX_XFILE | EX_NOSPC);
!     separate_nextcmd(eap);
      if (*eap->arg == '<' || *eap->arg == '$' || mch_isFullName(eap->arg))
      {
        // For an absolute path, "$VIM/..." or "<sfile>.." we ":source" the
--- 4764,4770 ----
       * filename to include.
       */
      eap->argt |= (EX_XFILE | EX_NOSPC);
!     separate_nextcmd(eap, FALSE);
      if (*eap->arg == '<' || *eap->arg == '$' || mch_isFullName(eap->arg))
      {
        // For an absolute path, "$VIM/..." or "<sfile>.." we ":source" the
*** ../vim-8.2.4614/src/vim9cmds.c      2022-03-22 20:42:09.178172849 +0000
--- src/vim9cmds.c      2022-03-23 19:35:57.426445227 +0000
***************
*** 1848,1854 ****
        if ((argt & EX_TRLBAR) && !usefilter)
        {
            eap->argt = argt;
!           separate_nextcmd(eap);
            if (eap->nextcmd != NULL)
                nextcmd = eap->nextcmd;
        }
--- 1848,1854 ----
        if ((argt & EX_TRLBAR) && !usefilter)
        {
            eap->argt = argt;
!           separate_nextcmd(eap, TRUE);
            if (eap->nextcmd != NULL)
                nextcmd = eap->nextcmd;
        }
*** ../vim-8.2.4614/src/testdir/test_vim9_cmd.vim       2022-03-20 
18:50:56.536291286 +0000
--- src/testdir/test_vim9_cmd.vim       2022-03-23 19:36:34.694143054 +0000
***************
*** 1178,1185 ****
        nnoremap <F3> :echo 'hit F3 #'<CR>
        assert_equal(":echo 'hit F3 #'<CR>", maparg("<F3>", "n"))
    END
!   v9.CheckDefSuccess(lines)
!   v9.CheckScriptSuccess(['vim9script'] + lines)
  enddef
  
  def Test_normal_command()
--- 1178,1196 ----
        nnoremap <F3> :echo 'hit F3 #'<CR>
        assert_equal(":echo 'hit F3 #'<CR>", maparg("<F3>", "n"))
    END
!   v9.CheckDefAndScriptSuccess(lines)
! 
!   # backslash before bar is not removed
!   lines =<< trim END
!       vim9script
! 
!       def Init()
!         noremap <buffer> <F5> <ScriptCmd>MyFunc('a') \| MyFunc('b')<CR>
!       enddef
!       Init()
!       unmap <buffer> <F5>
!   END
!   v9.CheckScriptSuccess(lines)
  enddef
  
  def Test_normal_command()
*** ../vim-8.2.4614/src/version.c       2022-03-23 14:55:19.709745872 +0000
--- src/version.c       2022-03-23 19:21:17.922674511 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4615,
  /**/

-- 
"A mouse can be just as dangerous as a bullet or a bomb."
             (US Representative Lamar Smith, R-Texas)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/20220323194536.6D15E1C0497%40moolenaar.net.

Raspunde prin e-mail lui