Patch 8.2.2888
Problem:    Vim9: "k" command recognized in Vim9 script.
Solution:   Do not recognize "k" or "s" and "d" with flags.
Files:      src/ex_docmd.c, src/testdir/test_vim9_builtin.vim,
            src/testdir/test_vim9_script.vim


*** ../vim-8.2.2887/src/ex_docmd.c      2021-05-26 19:49:06.420241287 +0200
--- src/ex_docmd.c      2021-05-26 20:58:59.482713942 +0200
***************
*** 3392,3399 ****
      int               len;
      char_u    *p;
      int               i;
  
- #ifdef FEAT_EVAL
      /*
       * Recognize a Vim9 script function/method call and assignment:
       * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
--- 3392,3402 ----
      int               len;
      char_u    *p;
      int               i;
+ #ifndef FEAT_EVAL
+     int               vim9 = FALSE;
+ #else
+     int               vim9 = in_vim9script();
  
      /*
       * Recognize a Vim9 script function/method call and assignment:
       * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
***************
*** 3556,3567 ****
       * - the "d" command can directly be followed by 'l' or 'p' flag.
       */
      p = eap->cmd;
!     if (*p == 'k')
      {
        eap->cmdidx = CMD_k;
        ++p;
      }
!     else if (p[0] == 's'
            && ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r'
                        && (p[3] == NUL || (p[3] != 'i' && p[4] != 'p')))))
                || p[1] == 'g'
--- 3559,3571 ----
       * - the "d" command can directly be followed by 'l' or 'p' flag.
       */
      p = eap->cmd;
!     if (!vim9 && *p == 'k')
      {
        eap->cmdidx = CMD_k;
        ++p;
      }
!     else if (!vim9
!           && p[0] == 's'
            && ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r'
                        && (p[3] == NUL || (p[3] != 'i' && p[4] != 'p')))))
                || p[1] == 'g'
***************
*** 3594,3600 ****
        if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#}", *p) != NULL)
            ++p;
        len = (int)(p - eap->cmd);
!       if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p'))
        {
            // Check for ":dl", ":dell", etc. to ":deletel": that's
            // :delete with the 'l' flag.  Same for 'p'.
--- 3598,3604 ----
        if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#}", *p) != NULL)
            ++p;
        len = (int)(p - eap->cmd);
!       if (!vim9 && *eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p'))
        {
            // Check for ":dl", ":dell", etc. to ":deletel": that's
            // :delete with the 'l' flag.  Same for 'p'.
***************
*** 3671,3677 ****
  
  #ifdef FEAT_EVAL
      if (eap->cmdidx < CMD_SIZE
!           && in_vim9script()
            && !IS_WHITE_OR_NUL(*p) && *p != '\n' && *p != '!'
            && (eap->cmdidx < 0 ||
                (cmdnames[eap->cmdidx].cmd_argt & EX_NONWHITE_OK) == 0))
--- 3675,3681 ----
  
  #ifdef FEAT_EVAL
      if (eap->cmdidx < CMD_SIZE
!           && vim9
            && !IS_WHITE_OR_NUL(*p) && *p != '\n' && *p != '!'
            && (eap->cmdidx < 0 ||
                (cmdnames[eap->cmdidx].cmd_argt & EX_NONWHITE_OK) == 0))
***************
*** 3802,3810 ****
--- 3806,3826 ----
  
      ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
      ea.cmdidx = (cmdidx_T)0;
+     ea.addr_count = 0;
      p = find_ex_command(&ea, NULL, NULL, NULL);
      if (p == NULL || ea.cmdidx == CMD_SIZE)
        return;
+     if (in_vim9script())
+     {
+       int          res;
+ 
+       ++emsg_silent;
+       res = not_in_vim9(&ea);
+       --emsg_silent;
+ 
+       if (res == FAIL)
+           return;
+     }
  
      rettv->vval.v_string = vim_strsave(IS_USER_CMDIDX(ea.cmdidx)
                                    ? get_user_commands(NULL, ea.useridx)
*** ../vim-8.2.2887/src/testdir/test_vim9_builtin.vim   2021-05-25 
20:13:56.316778428 +0200
--- src/testdir/test_vim9_builtin.vim   2021-05-26 20:59:41.650611278 +0200
***************
*** 554,559 ****
--- 554,582 ----
    res->assert_equal({aa: [1], ac: [3]})
  enddef
  
+ def Test_fullcommand()
+   assert_equal('next', fullcommand('n'))
+   assert_equal('noremap', fullcommand('no'))
+   assert_equal('noremap', fullcommand('nor'))
+   assert_equal('normal', fullcommand('norm'))
+ 
+   assert_equal('', fullcommand('k'))
+   assert_equal('keepmarks', fullcommand('ke'))
+   assert_equal('keepmarks', fullcommand('kee'))
+   assert_equal('keepmarks', fullcommand('keep'))
+   assert_equal('keepjumps', fullcommand('keepj'))
+ 
+   assert_equal('dlist', fullcommand('dl'))
+   assert_equal('', fullcommand('dp'))
+   assert_equal('delete', fullcommand('del'))
+   assert_equal('', fullcommand('dell'))
+   assert_equal('', fullcommand('delp'))
+ 
+   assert_equal('srewind', fullcommand('sre'))
+   assert_equal('scriptnames', fullcommand('scr'))
+   assert_equal('', fullcommand('scg'))
+ enddef
+ 
  def Test_garbagecollect()
    garbagecollect(true)
  enddef
*** ../vim-8.2.2887/src/testdir/test_vim9_script.vim    2021-05-22 
21:40:35.385799988 +0200
--- src/testdir/test_vim9_script.vim    2021-05-26 21:05:18.341796436 +0200
***************
*** 3844,3855 ****
    var lines =<< trim END
        ka
    END
!   CheckDefAndScriptFailure(lines, 'E1100:')
  
    lines =<< trim END
        :1ka
    END
!   CheckDefAndScriptFailure(lines, 'E481:')
  
    lines =<< trim END
      t
--- 3844,3857 ----
    var lines =<< trim END
        ka
    END
!   CheckDefFailure(lines, 'E476:')
!   CheckScriptFailure(['vim9script'] + lines, 'E492:')
  
    lines =<< trim END
        :1ka
    END
!   CheckDefFailure(lines, 'E476:')
!   CheckScriptFailure(['vim9script'] + lines, 'E492:')
  
    lines =<< trim END
      t
*** ../vim-8.2.2887/src/version.c       2021-05-26 19:49:06.420241287 +0200
--- src/version.c       2021-05-26 21:09:06.665247039 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2888,
  /**/

-- 
"It's so simple to be wise.  Just think of something stupid to say
and then don't say it."        -- Sam Levenson

 /// 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/202105261910.14QJAgaI793940%40masaka.moolenaar.net.

Raspunde prin e-mail lui