Patch 9.0.1636
Problem:    Expanding a pattern interferes with command line completion.
Solution:   Set the file index only when appropriate. (closes #12519)
Files:      src/cmdexpand.c, src/testdir/test_cmdline.vim


*** ../vim-9.0.1635/src/cmdexpand.c     2023-05-20 14:06:56.669542805 +0100
--- src/cmdexpand.c     2023-06-15 22:48:58.833639165 +0100
***************
*** 957,963 ****
      int               mode)
  {
      char_u    *ss = NULL;
!     static int        findex;
      static char_u *orig_save = NULL;  // kept value of orig
      int               orig_saved = FALSE;
      int               i;
--- 957,963 ----
      int               mode)
  {
      char_u    *ss = NULL;
!     static int        findex;                 // TODO: Move into expand_T
      static char_u *orig_save = NULL;  // kept value of orig
      int               orig_saved = FALSE;
      int               i;
***************
*** 971,978 ****
      if (mode == WILD_CANCEL)
        ss = vim_strsave(orig_save ? orig_save : (char_u *)"");
      else if (mode == WILD_APPLY)
!       ss = vim_strsave(findex == -1 ? (orig_save ?
!                   orig_save : (char_u *)"") : xp->xp_files[findex]);
  
      // free old names
      if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST)
--- 971,979 ----
      if (mode == WILD_CANCEL)
        ss = vim_strsave(orig_save ? orig_save : (char_u *)"");
      else if (mode == WILD_APPLY)
!       ss = vim_strsave(findex == -1
!                           ? (orig_save ? orig_save : (char_u *)"")
!                           : xp->xp_files[findex]);
  
      // free old names
      if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST)
***************
*** 985,991 ****
        if (compl_match_array != NULL)
            cmdline_pum_remove();
      }
!     findex = 0;
  
      if (mode == WILD_FREE)    // only release file name
        return NULL;
--- 986,994 ----
        if (compl_match_array != NULL)
            cmdline_pum_remove();
      }
!     // TODO: Remove condition if "findex" is part of expand_T ?
!     if (mode != WILD_EXPAND_FREE && mode != WILD_ALL && mode != WILD_ALL_KEEP)
!       findex = 0;
  
      if (mode == WILD_FREE)    // only release file name
        return NULL;
*** ../vim-9.0.1635/src/testdir/test_cmdline.vim        2023-05-19 
21:40:57.854218815 +0100
--- src/testdir/test_cmdline.vim        2023-06-15 22:45:43.109701709 +0100
***************
*** 1336,1341 ****
--- 1336,1365 ----
    call assert_equal('"py3file', @:)
  endfunc
  
+ " Test that expanding a pattern doesn't interfere with cmdline completion.
+ func Test_expand_during_cmdline_completion()
+   func ExpandStuff()
+     badd <script>:p:h/README.*
+     call assert_equal(expand('<script>:p:h') .. '/README.txt', bufname('$'))
+     $bwipe
+     call assert_equal('README.txt', expand('README.*'))
+     call assert_equal(['README.txt'], getcompletion('README.*', 'file'))
+   endfunc
+   augroup test_CmdlineChanged
+     autocmd!
+     autocmd CmdlineChanged * call ExpandStuff()
+   augroup END
+ 
+   call feedkeys(":sign \<Tab>\<Tab>\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt')
+   call assert_equal('"sign place', @:)
+ 
+   augroup test_CmdlineChanged
+     au!
+   augroup END
+   augroup! test_CmdlineChanged
+   delfunc ExpandStuff
+ endfunc
+ 
  " Test for 'wildignorecase'
  func Test_cmdline_wildignorecase()
    CheckUnix
***************
*** 1675,1680 ****
--- 1699,1705 ----
    augroup test_cmd_filter_E135
      au!
    augroup END
+   augroup! test_cmd_filter_E135
    %bwipe!
  endfunc
  
***************
*** 2134,2140 ****
  func Test_cmd_map_cmdlineChanged()
    let g:log = []
    cnoremap <F1> l<Cmd><CR>s
!   augroup test
      autocmd!
      autocmd CmdlineChanged : let g:log += [getcmdline()]
    augroup END
--- 2159,2165 ----
  func Test_cmd_map_cmdlineChanged()
    let g:log = []
    cnoremap <F1> l<Cmd><CR>s
!   augroup test_CmdlineChanged
      autocmd!
      autocmd CmdlineChanged : let g:log += [getcmdline()]
    augroup END
***************
*** 2150,2158 ****
  
    unlet g:log
    cunmap <F1>
!   augroup test
      autocmd!
    augroup END
  endfunc
  
  " Test for the 'suffixes' option
--- 2175,2184 ----
  
    unlet g:log
    cunmap <F1>
!   augroup test_CmdlineChanged
      autocmd!
    augroup END
+   augroup! test_CmdlineChanged
  endfunc
  
  " Test for the 'suffixes' option
*** ../vim-9.0.1635/src/version.c       2023-06-15 18:44:30.730482948 +0100
--- src/version.c       2023-06-15 22:47:40.573661788 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1636,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
182. You may not know what is happening in the world, but you know
     every bit of net-gossip there is.

 /// 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/20230615215228.44DEC1C10D4%40moolenaar.net.

Raspunde prin e-mail lui