Patch 8.2.3638
Problem:    getcompletion() always passes zero as position to custom
            completion function.
Solution:   Pass the pattern length. (closes #9173)
Files:      src/cmdexpand.c, src/testdir/test_cmdline.vim


*** ../vim-8.2.3637/src/cmdexpand.c     2021-10-21 11:39:49.825486269 +0100
--- src/cmdexpand.c     2021-11-21 11:52:08.683454021 +0000
***************
*** 2900,2905 ****
--- 2900,2906 ----
                || check_for_opt_bool_arg(argvars, 2) == FAIL))
        return;
  
+     pat = tv_get_string(&argvars[0]);
      if (argvars[1].v_type != VAR_STRING)
      {
        semsg(_(e_invarg2), "type must be a string");
***************
*** 2920,2931 ****
      ExpandInit(&xpc);
      if (STRCMP(type, "cmdline") == 0)
      {
!       set_one_cmd_context(&xpc, tv_get_string(&argvars[0]));
        xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
      }
      else
      {
!       xpc.xp_pattern = tv_get_string(&argvars[0]);
        xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
  
        xpc.xp_context = cmdcomplete_str_to_type(type);
--- 2921,2933 ----
      ExpandInit(&xpc);
      if (STRCMP(type, "cmdline") == 0)
      {
!       set_one_cmd_context(&xpc, pat);
        xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
+       xpc.xp_col = (int)STRLEN(pat);
      }
      else
      {
!       xpc.xp_pattern = pat;
        xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
  
        xpc.xp_context = cmdcomplete_str_to_type(type);
*** ../vim-8.2.3637/src/testdir/test_cmdline.vim        2021-11-17 
14:01:10.470090290 +0000
--- src/testdir/test_cmdline.vim        2021-11-21 11:47:36.216002439 +0000
***************
*** 424,437 ****
--- 424,440 ----
    call assert_equal([], l)
  
    func T(a, c, p)
+     let g:cmdline_compl_params = [a:a, a:c, a:p]
      return "oneA\noneB\noneC"
    endfunc
    command -nargs=1 -complete=custom,T MyCmd
    let l = getcompletion('MyCmd ', 'cmdline')
    call assert_equal(['oneA', 'oneB', 'oneC'], l)
+   call assert_equal(['', 'MyCmd ', 6], g:cmdline_compl_params)
  
    delcommand MyCmd
    delfunc T
+   unlet g:cmdline_compl_params
  
    " For others test if the name is recognized.
    let names = ['buffer', 'environment', 'file_in_path', 'mapping', 'tag', 
'tag_listfiles', 'user']
*** ../vim-8.2.3637/src/version.c       2021-11-21 11:35:59.460938795 +0000
--- src/version.c       2021-11-21 11:51:27.955539288 +0000
***************
*** 759,760 ****
--- 759,762 ----
  {   /* Add new patch number below this line */
+ /**/
+     3638,
  /**/

-- 
Compilation process failed successfully.

 /// 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/20211121121607.0DC2E1C3DCA%40moolenaar.net.

Raspunde prin e-mail lui