Patch 8.2.2955
Problem:    Vim9: using filter in compiled command does not work.
Solution:   Generate EXEC including the command modifier.
Files:      src/vim9compile.c, src/ex_docmd.c, src/ex_cmds.c,
            src/proto/ex_cmds.pro, src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.2954/src/vim9compile.c   2021-06-06 17:02:49.753789485 +0200
--- src/vim9compile.c   2021-06-06 21:12:27.808748767 +0200
***************
*** 8536,8548 ****
      static char_u *
  compile_exec(char_u *line, exarg_T *eap, cctx_T *cctx)
  {
!     char_u  *p;
!     int           has_expr = FALSE;
!     char_u  *nextcmd = (char_u *)"";
  
      if (cctx->ctx_skip == SKIP_YES)
        goto theend;
  
      if (eap->cmdidx >= 0 && eap->cmdidx < CMD_SIZE)
      {
        long    argt = eap->argt;
--- 8536,8565 ----
      static char_u *
  compile_exec(char_u *line, exarg_T *eap, cctx_T *cctx)
  {
!     char_u    *p;
!     int               has_expr = FALSE;
!     char_u    *nextcmd = (char_u *)"";
  
      if (cctx->ctx_skip == SKIP_YES)
        goto theend;
  
+     // If there was a prececing command modifier, drop it and include it in 
the
+     // EXEC command.
+     if (cctx->ctx_has_cmdmod)
+     {
+       garray_T        *instr = &cctx->ctx_instr;
+       isn_T           *isn = ((isn_T *)instr->ga_data) + instr->ga_len - 1;
+ 
+       if (isn->isn_type == ISN_CMDMOD)
+       {
+           vim_regfree(isn->isn_arg.cmdmod.cf_cmdmod
+                                              ->cmod_filter_regmatch.regprog);
+           vim_free(isn->isn_arg.cmdmod.cf_cmdmod);
+           --instr->ga_len;
+           cctx->ctx_has_cmdmod = FALSE;
+       }
+     }
+ 
      if (eap->cmdidx >= 0 && eap->cmdidx < CMD_SIZE)
      {
        long    argt = eap->argt;
*** ../vim-8.2.2954/src/ex_docmd.c      2021-06-02 13:28:11.427120469 +0200
--- src/ex_docmd.c      2021-06-06 21:23:50.663662393 +0200
***************
*** 2881,2887 ****
  
            case 'f':   // only accept ":filter {pat} cmd"
                        {
!                           char_u *reg_pat;
  
                            if (!checkforcmd_noparen(&p, "filter", 4)
                                                || *p == NUL || ends_excmd(*p))
--- 2881,2889 ----
  
            case 'f':   // only accept ":filter {pat} cmd"
                        {
!                           char_u  *reg_pat;
!                           char_u  *nulp = NULL;
!                           int     c = 0;
  
                            if (!checkforcmd_noparen(&p, "filter", 4)
                                                || *p == NUL || ends_excmd(*p))
***************
*** 2902,2908 ****
                                p = skip_vimgrep_pat(p, NULL, NULL);
                            else
                                // NOTE: This puts a NUL after the pattern.
!                               p = skip_vimgrep_pat(p, &reg_pat, NULL);
                            if (p == NULL || *p == NUL)
                                break;
                            if (!skip_only)
--- 2904,2911 ----
                                p = skip_vimgrep_pat(p, NULL, NULL);
                            else
                                // NOTE: This puts a NUL after the pattern.
!                               p = skip_vimgrep_pat_ext(p, &reg_pat, NULL,
!                                                                   &nulp, &c);
                            if (p == NULL || *p == NUL)
                                break;
                            if (!skip_only)
***************
*** 2911,2916 ****
--- 2914,2922 ----
                                                vim_regcomp(reg_pat, RE_MAGIC);
                                if (cmod->cmod_filter_regmatch.regprog == NULL)
                                    break;
+                               // restore the character overwritten by NUL
+                               if (nulp != NULL)
+                                   *nulp = c;
                            }
                            eap->cmd = p;
                            continue;
*** ../vim-8.2.2954/src/ex_cmds.c       2021-05-15 23:21:00.799930024 +0200
--- src/ex_cmds.c       2021-06-06 21:24:11.587629004 +0200
***************
*** 5278,5283 ****
--- 5278,5293 ----
      char_u *
  skip_vimgrep_pat(char_u *p, char_u **s, int *flags)
  {
+     return skip_vimgrep_pat_ext(p, s, flags, NULL, NULL);
+ }
+ 
+ /*
+  * As skip_vimgrep_pat() and store the character overwritten by NUL in "cp"
+  * and the pointer to it in "nulp".
+  */
+     char_u *
+ skip_vimgrep_pat_ext(char_u *p, char_u **s, int *flags, char_u **nulp, int 
*cp)
+ {
      int               c;
  
      if (vim_isIDc(*p))
***************
*** 5287,5293 ****
--- 5297,5310 ----
            *s = p;
        p = skiptowhite(p);
        if (s != NULL && *p != NUL)
+       {
+           if (nulp != NULL)
+           {
+               *nulp = p;
+               *cp = *p;
+           }
            *p++ = NUL;
+       }
      }
      else
      {
***************
*** 5301,5307 ****
--- 5318,5331 ----
  
        // Truncate the pattern.
        if (s != NULL)
+       {
+           if (nulp != NULL)
+           {
+               *nulp = p;
+               *cp = *p;
+           }
            *p = NUL;
+       }
        ++p;
  
        // Find the flags
*** ../vim-8.2.2954/src/proto/ex_cmds.pro       2021-04-19 16:48:44.435055499 
+0200
--- src/proto/ex_cmds.pro       2021-06-06 21:24:15.507622735 +0200
***************
*** 39,43 ****
--- 39,44 ----
  void ex_smile(exarg_T *eap);
  void ex_drop(exarg_T *eap);
  char_u *skip_vimgrep_pat(char_u *p, char_u **s, int *flags);
+ char_u *skip_vimgrep_pat_ext(char_u *p, char_u **s, int *flags, char_u 
**nulp, int *cp);
  void ex_oldfiles(exarg_T *eap);
  /* vim: set ft=c : */
*** ../vim-8.2.2954/src/testdir/test_vim9_cmd.vim       2021-06-05 
21:36:16.390016558 +0200
--- src/testdir/test_vim9_cmd.vim       2021-06-06 21:32:44.510808148 +0200
***************
*** 534,539 ****
--- 534,547 ----
      assert_equal(execute('filter /piyo/ registers abc'), expected)
    END
    CheckDefAndScriptSuccess(lines)
+ 
+   # also do this compiled
+   lines =<< trim END
+       @a = 'very specific z3d37dh234 string'
+       filter z3d37dh234 registers
+       assert_match('very specific z3d37dh234 string', Screenline(&lines))
+   END
+   CheckDefAndScriptSuccess(lines)
  enddef
  
  def Test_win_command_modifiers()
*** ../vim-8.2.2954/src/version.c       2021-06-06 20:15:49.880755525 +0200
--- src/version.c       2021-06-06 21:02:39.009670116 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2955,
  /**/

-- 
Wi n0t trei a h0liday in Sweden thi yer?
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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/202106061938.156JcquL396488%40masaka.moolenaar.net.

Raspunde prin e-mail lui