Patch 8.2.4387
Problem:    Command line completion doesn't always work properly.
Solution:   Adjust triggering after a "|".  Add more tests. (Yegappan
            Lakshmanan, closes #9779)
Files:      src/cmdexpand.c, src/testdir/test_cmdline.vim


*** ../vim-8.2.4386/src/cmdexpand.c     2022-02-13 11:45:05.407225148 +0000
--- src/cmdexpand.c     2022-02-15 11:31:16.076795357 +0000
***************
*** 1473,1488 ****
                // skip "from" part
                ++arg;
                arg = skip_regexp(arg, delim, magic_isset());
!           }
!           // skip "to" part
!           while (arg[0] != NUL && arg[0] != delim)
!           {
!               if (arg[0] == '\\' && arg[1] != NUL)
                    ++arg;
!               ++arg;
            }
-           if (arg[0] != NUL)  // skip delimiter
-               ++arg;
            while (arg[0] && vim_strchr((char_u *)"|\"#", arg[0]) == NULL)
                ++arg;
            if (arg[0] != NUL)
--- 1473,1493 ----
                // skip "from" part
                ++arg;
                arg = skip_regexp(arg, delim, magic_isset());
! 
!               if (arg[0] != NUL && arg[0] == delim)
!               {
!                   // skip "to" part
                    ++arg;
!                   while (arg[0] != NUL && arg[0] != delim)
!                   {
!                       if (arg[0] == '\\' && arg[1] != NUL)
!                           ++arg;
!                       ++arg;
!                   }
!                   if (arg[0] != NUL)  // skip delimiter
!                       ++arg;
!               }
            }
            while (arg[0] && vim_strchr((char_u *)"|\"#", arg[0]) == NULL)
                ++arg;
            if (arg[0] != NUL)
***************
*** 1508,1514 ****
                    arg = skipwhite(arg + 1);
  
                    // Check for trailing illegal characters
!                   if (*arg && vim_strchr((char_u *)"|\"\n", *arg) == NULL)
                        xp->xp_context = EXPAND_NOTHING;
                    else
                        return arg;
--- 1513,1520 ----
                    arg = skipwhite(arg + 1);
  
                    // Check for trailing illegal characters
!                   if (*arg == NUL ||
!                               vim_strchr((char_u *)"|\"\n", *arg) == NULL)
                        xp->xp_context = EXPAND_NOTHING;
                    else
                        return arg;
***************
*** 2408,2413 ****
--- 2414,2421 ----
        int len = (int)STRLEN(pat) + 20;
  
        tofree = alloc(len);
+       if (tofree == NULL)
+           return FAIL;
        vim_snprintf((char *)tofree, len, "^<SNR>\\d\\+_%s", pat + 3);
        pat = tofree;
      }
*** ../vim-8.2.4386/src/testdir/test_cmdline.vim        2022-02-14 
19:17:25.220143635 +0000
--- src/testdir/test_cmdline.vim        2022-02-15 11:31:16.080795346 +0000
***************
*** 264,272 ****
  func Test_match_completion()
    hi Aardig ctermfg=green
    call feedkeys(":match \<Tab>\<Home>\"\<CR>", 'xt')
!   call assert_equal('"match Aardig', getreg(':'))
    call feedkeys(":match \<S-Tab>\<Home>\"\<CR>", 'xt')
!   call assert_equal('"match none', getreg(':'))
  endfunc
  
  func Test_highlight_completion()
--- 264,274 ----
  func Test_match_completion()
    hi Aardig ctermfg=green
    call feedkeys(":match \<Tab>\<Home>\"\<CR>", 'xt')
!   call assert_equal('"match Aardig', @:)
    call feedkeys(":match \<S-Tab>\<Home>\"\<CR>", 'xt')
!   call assert_equal('"match none', @:)
!   call feedkeys(":match | chist\<Tab>\<C-B>\"\<CR>", 'xt')
!   call assert_equal('"match | chistory', @:)
  endfunc
  
  func Test_highlight_completion()
***************
*** 387,392 ****
--- 389,399 ----
    let l = getcompletion('run', 'file', 1)
    call assert_true(index(l, 'runtest.vim') < 0)
    set wildignore&
+   " Directory name with space character
+   call mkdir('Xdir with space')
+   call assert_equal(['Xdir with space/'], getcompletion('Xdir\ w', 
'shellcmd'))
+   call assert_equal(['./Xdir with space/'], getcompletion('./Xdir', 
'shellcmd'))
+   call delete('Xdir with space', 'd')
  
    let l = getcompletion('ha', 'filetype')
    call assert_true(index(l, 'hamster') >= 0)
***************
*** 608,614 ****
    call mkdir('a/b', 'p')
    call writefile(['asdfasdf'], 'a/b/fileXname')
    call feedkeys(":find **/fileXname\<Tab>\<CR>", 'xt')
!   call assert_equal('find a/b/fileXname', getreg(':'))
    bwipe!
    call delete('a', 'rf')
  endfunc
--- 615,621 ----
    call mkdir('a/b', 'p')
    call writefile(['asdfasdf'], 'a/b/fileXname')
    call feedkeys(":find **/fileXname\<Tab>\<CR>", 'xt')
!   call assert_equal('find a/b/fileXname', @:)
    bwipe!
    call delete('a', 'rf')
  endfunc
***************
*** 742,747 ****
--- 749,760 ----
    call assert_equal('"Foo blue', @:)
    call feedkeys(":Foo b\<Tab>\<Home>\"\<cr>", 'tx')
    call assert_equal('"Foo blue', @:)
+   call feedkeys(":Foo a b\<Tab>\<Home>\"\<cr>", 'tx')
+   call assert_equal('"Foo a blue', @:)
+   call feedkeys(":Foo b\\\<Tab>\<Home>\"\<cr>", 'tx')
+   call assert_equal('"Foo b\', @:)
+   call feedkeys(":Foo b\\x\<Tab>\<Home>\"\<cr>", 'tx')
+   call assert_equal('"Foo b\x', @:)
    delcommand Foo
  endfunc
  
***************
*** 953,966 ****
    call feedkeys(":match Search /pat/\<C-A>\<C-B>\"\<CR>", 'xt')
    call assert_equal("\"match Search /pat/\<C-A>", @:)
  
-   " completion for the :s command
-   call feedkeys(":s/from/to/g\<C-A>\<C-B>\"\<CR>", 'xt')
-   call assert_equal("\"s/from/to/g\<C-A>", @:)
- 
-   " completion for the :dlist command
-   call feedkeys(":dlist 10 /pat/ a\<C-A>\<C-B>\"\<CR>", 'xt')
-   call assert_equal("\"dlist 10 /pat/ a\<C-A>", @:)
- 
    " completion for the :doautocmd command
    call feedkeys(":doautocmd User MyCmd a.c\<C-A>\<C-B>\"\<CR>", 'xt')
    call assert_equal("\"doautocmd User MyCmd a.c\<C-A>", @:)
--- 966,971 ----
***************
*** 1068,1073 ****
--- 1073,1084 ----
    call feedkeys(":1,10 | chist\t\<C-B>\"\<CR>", 'xt')
    call assert_equal('"1,10 | chistory', @:)
  
+   " completion after a :global command
+   call feedkeys(":g/a/chist\t\<C-B>\"\<CR>", 'xt')
+   call assert_equal('"g/a/chistory', @:)
+   call feedkeys(":g/a\\/chist\t\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"g/a\\/chist\t", @:)
+ 
    " use <Esc> as the 'wildchar' for completion
    set wildchar=<Esc>
    call feedkeys(":g/a\\xb/clearj\<Esc>\<C-B>\"\<CR>", 'xt')
***************
*** 1077,1088 ****
    call assert_equal('"g/a\xb/clearjumps', @:)
    set wildchar&
  
-   " should be able to complete a file name that starts with a '~'.
    if has('unix')
      call writefile([], '~Xtest')
      call feedkeys(":e \\~X\<Tab>\<C-B>\"\<CR>", 'xt')
      call assert_equal('"e \~Xtest', @:)
      call delete('~Xtest')
    endif
  
    call feedkeys(":py3f\<Tab>\<C-B>\"\<CR>", 'xt')
--- 1088,1105 ----
    call assert_equal('"g/a\xb/clearjumps', @:)
    set wildchar&
  
    if has('unix')
+     " should be able to complete a file name that starts with a '~'.
      call writefile([], '~Xtest')
      call feedkeys(":e \\~X\<Tab>\<C-B>\"\<CR>", 'xt')
      call assert_equal('"e \~Xtest', @:)
      call delete('~Xtest')
+ 
+     " should be able to complete a file name that has a '*'
+     call writefile([], 'Xx*Yy')
+     call feedkeys(":e Xx\*\<Tab>\<C-B>\"\<CR>", 'xt')
+     call assert_equal('"e Xx\*Yy', @:)
+     call delete('Xx*Yy')
    endif
  
    call feedkeys(":py3f\<Tab>\<C-B>\"\<CR>", 'xt')
***************
*** 1097,1102 ****
--- 1114,1123 ----
    call feedkeys(":e xt\<Tab>\<C-B>\"\<CR>", 'xt')
    call assert_equal('"e XTEST', @:)
    call assert_equal(['XTEST'], getcompletion('xt', 'file'))
+   let g:Sline = ''
+   call feedkeys(":e xt\<C-d>\<F4>\<C-B>\"\<CR>", 'xt')
+   call assert_equal('"e xt', @:)
+   call assert_equal('XTEST', g:Sline)
    set wildignorecase&
    call delete('XTEST')
  endfunc
***************
*** 1153,1159 ****
    " If only the tick is passed as a range and no command is specified, there
    " should not be an error
    call feedkeys(":'\<CR>", 'xt')
!   call assert_equal("'", getreg(':'))
    call assert_fails("',print", 'E78:')
  endfunc
  
--- 1174,1180 ----
    " If only the tick is passed as a range and no command is specified, there
    " should not be an error
    call feedkeys(":'\<CR>", 'xt')
!   call assert_equal("'", @:)
    call assert_fails("',print", 'E78:')
  endfunc
  
***************
*** 1725,1730 ****
--- 1746,1771 ----
    call assert_equal('"e a1b2y3z4', @:)
    set wildmenu&
  
+   " Test for longest file name completion with 'fileignorecase'
+   " On MS-Windows, file names are case insensitive.
+   if has('unix')
+     call writefile([], 'XTESTfoo')
+     call writefile([], 'Xtestbar')
+     set nofileignorecase
+     call feedkeys(":e XT\<Tab>\<C-B>\"\<CR>", 'xt')
+     call assert_equal('"e XTESTfoo', @:)
+     call feedkeys(":e Xt\<Tab>\<C-B>\"\<CR>", 'xt')
+     call assert_equal('"e Xtestbar', @:)
+     set fileignorecase
+     call feedkeys(":e XT\<Tab>\<C-B>\"\<CR>", 'xt')
+     call assert_equal('"e Xtest', @:)
+     call feedkeys(":e Xt\<Tab>\<C-B>\"\<CR>", 'xt')
+     call assert_equal('"e Xtest', @:)
+     set fileignorecase&
+     call delete('XTESTfoo')
+     call delete('Xtestbar')
+   endif
+ 
    %argdelete
    delcommand MyCmd
    delfunc T
***************
*** 1764,1769 ****
--- 1805,1818 ----
    endtry
    call assert_equal(1, interrupted)
  
+   let interrupted = 0
+   try
+     call feedkeys(":Tcmd tw\<C-d>\<C-B>\"\<CR>", 'xt')
+   catch /^Vim:Interrupt$/
+     let interrupted = 1
+   endtry
+   call assert_equal(1, interrupted)
+ 
    delcommand Tcmd
    delfunc F
    set wildmode&
***************
*** 2336,2339 ****
--- 2385,2431 ----
    cunmap <F2>
  endfunc
  
+ " Test for completion after a :substitute command followed by a pipe (|)
+ " character
+ func Test_cmdline_complete_substitute()
+   call feedkeys(":s | \t\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"s | \t", @:)
+   call feedkeys(":s/ | \t\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"s/ | \t", @:)
+   call feedkeys(":s/one | \t\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"s/one | \t", @:)
+   call feedkeys(":s/one/ | \t\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"s/one/ | \t", @:)
+   call feedkeys(":s/one/two | \t\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"s/one/two | \t", @:)
+   call feedkeys(":s/one/two/ | chist\t\<C-B>\"\<CR>", 'xt')
+   call assert_equal('"s/one/two/ | chistory', @:)
+   call feedkeys(":s/one/two/g \t\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"s/one/two/g \t", @:)
+   call feedkeys(":s/one/two/g | chist\t\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"s/one/two/g | chistory", @:)
+   call feedkeys(":s/one/t\\/ | \t\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"s/one/t\\/ | \t", @:)
+   call feedkeys(":s/one/t\"o/ | chist\t\<C-B>\"\<CR>", 'xt')
+   call assert_equal('"s/one/t"o/ | chistory', @:)
+   call feedkeys(":s/one/t|o/ | chist\t\<C-B>\"\<CR>", 'xt')
+   call assert_equal('"s/one/t|o/ | chistory', @:)
+   call feedkeys(":&\t\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"&\t", @:)
+ endfunc
+ 
+ " Test for the :dlist command completion
+ func Test_cmdline_complete_dlist()
+   call feedkeys(":dlist 10 /pat/ a\<C-A>\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"dlist 10 /pat/ a\<C-A>", @:)
+   call feedkeys(":dlist 10 /pat/ \t\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"dlist 10 /pat/ \t", @:)
+   call feedkeys(":dlist 10 /pa\\t/\t\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"dlist 10 /pa\\t/\t", @:)
+   call feedkeys(":dlist 10 /pat\\\t\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"dlist 10 /pat\\\t", @:)
+   call feedkeys(":dlist 10 /pat/ | chist\<Tab>\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"dlist 10 /pat/ | chistory", @:)
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.4386/src/version.c       2022-02-14 21:51:42.507756075 +0000
--- src/version.c       2022-02-15 11:34:52.708203799 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4387,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
39. You move into a new house and setup the Wifi router before
    unpacking any kitchen stuff.

 /// 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/20220215113659.C9C461C0E01%40moolenaar.net.

Raspunde prin e-mail lui