Patch 8.2.4618
Problem:    Command line completion does not recognize single letter commands.
Solution:   Use the condition from find_ex_command().
Files:      src/ex_docmd.c


*** ../vim-8.2.4617/src/ex_docmd.c      2022-03-23 19:44:56.098161437 +0000
--- src/ex_docmd.c      2022-03-24 13:07:29.803912969 +0000
***************
*** 3421,3426 ****
--- 3421,3458 ----
  #endif
  
  /*
+  * Return TRUE and set "*idx" if "p" points to a one letter command.
+  * If not in Vim9 script:
+  * - The 'k' command can directly be followed by any character.
+  * - The 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
+  *        but :sre[wind] is another command, as are :scr[iptnames],
+  *        :scs[cope], :sim[alt], :sig[ns] and :sil[ent].
+  */
+     static int
+ one_letter_cmd(char_u *p, cmdidx_T *idx)
+ {
+     if (!in_vim9script())
+       return FALSE;
+     if (*p == 'k')
+     {
+       *idx = CMD_k;
+       return TRUE;
+     }
+     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'
+               || (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g')
+               || p[1] == 'I'
+               || (p[1] == 'r' && p[2] != 'e')))
+     {
+       *idx = CMD_substitute;
+       return TRUE;
+     }
+     return FALSE;
+ }
+ 
+ /*
   * Find an Ex command by its name, either built-in or user.
   * Start of the name can be found at eap->cmd.
   * Sets eap->cmdidx and returns a pointer to char after the command name.
***************
*** 3654,3683 ****
  
      /*
       * Isolate the command and search for it in the command table.
-      * Exceptions:
-      * - The 'k' command can directly be followed by any character.
-      *   But it is not used in Vim9 script.
-      * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
-      *            but :sre[wind] is another command, as are :scr[iptnames],
-      *            :scs[cope], :sim[alt], :sig[ns] and :sil[ent].
-      * - 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'
!               || (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g')
!               || p[1] == 'I'
!               || (p[1] == 'r' && p[2] != 'e')))
      {
-       eap->cmdidx = CMD_substitute;
        ++p;
      }
      else
--- 3686,3695 ----
  
      /*
       * Isolate the command and search for it in the command table.
       */
      p = eap->cmd;
!     if (one_letter_cmd(p, &eap->cmdidx))
      {
        ++p;
      }
      else
***************
*** 3702,3707 ****
--- 3714,3721 ----
        if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#}", *p) != NULL)
            ++p;
        len = (int)(p - eap->cmd);
+       // The "d" command can directly be followed by 'l' or 'p' flag, when
+       // not in Vim9 script.
        if (!vim9 && *eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p'))
        {
            // Check for ":dl", ":dell", etc. to ":deletel": that's
***************
*** 3955,3964 ****
  {
      cmdidx_T idx;
  
!     for (idx = (cmdidx_T)0; (int)idx < (int)CMD_SIZE;
!           idx = (cmdidx_T)((int)idx + 1))
!       if (STRNCMP(cmdnames[(int)idx].cmd_name, cmd, (size_t)len) == 0)
!           break;
  
      return idx;
  }
--- 3969,3979 ----
  {
      cmdidx_T idx;
  
!     if (!one_letter_cmd(cmd, &idx))
!       for (idx = (cmdidx_T)0; (int)idx < (int)CMD_SIZE;
!               idx = (cmdidx_T)((int)idx + 1))
!           if (STRNCMP(cmdnames[(int)idx].cmd_name, cmd, (size_t)len) == 0)
!               break;
  
      return idx;
  }
*** ../vim-8.2.4617/src/version.c       2022-03-24 11:22:07.219294092 +0000
--- src/version.c       2022-03-24 13:01:44.932420328 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4618,
  /**/

-- 
GUARD #2:  It could be carried by an African swallow!
GUARD #1:  Oh, yeah, an African swallow maybe, but not a European swallow,
           that's my point.
GUARD #2:  Oh, yeah, I agree with that...
                                  The Quest for the Holy Grail (Monty Python)

 /// 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/20220324130932.136CB1C08FD%40moolenaar.net.

Raspunde prin e-mail lui