To: vim_dev@googlegroups.com Subject: Patch 8.2.4387 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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, "^\\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 \\\"\", 'xt') ! call assert_equal('"match Aardig', getreg(':')) call feedkeys(":match \\\"\", '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 \\\"\", 'xt') ! call assert_equal('"match Aardig', @:) call feedkeys(":match \\\"\", 'xt') ! call assert_equal('"match none', @:) ! call feedkeys(":match | chist\\\"\", '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\\", '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\\", '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\\\"\", 'tx') call assert_equal('"Foo blue', @:) + call feedkeys(":Foo a b\\\"\", 'tx') + call assert_equal('"Foo a blue', @:) + call feedkeys(":Foo b\\\\\"\", 'tx') + call assert_equal('"Foo b\', @:) + call feedkeys(":Foo b\\x\\\"\", 'tx') + call assert_equal('"Foo b\x', @:) delcommand Foo endfunc *************** *** 953,966 **** call feedkeys(":match Search /pat/\\\"\", 'xt') call assert_equal("\"match Search /pat/\", @:) - " completion for the :s command - call feedkeys(":s/from/to/g\\\"\", 'xt') - call assert_equal("\"s/from/to/g\", @:) - - " completion for the :dlist command - call feedkeys(":dlist 10 /pat/ a\\\"\", 'xt') - call assert_equal("\"dlist 10 /pat/ a\", @:) - " completion for the :doautocmd command call feedkeys(":doautocmd User MyCmd a.c\\\"\", 'xt') call assert_equal("\"doautocmd User MyCmd a.c\", @:) --- 966,971 ---- *************** *** 1068,1073 **** --- 1073,1084 ---- call feedkeys(":1,10 | chist\t\\"\", 'xt') call assert_equal('"1,10 | chistory', @:) + " completion after a :global command + call feedkeys(":g/a/chist\t\\"\", 'xt') + call assert_equal('"g/a/chistory', @:) + call feedkeys(":g/a\\/chist\t\\"\", 'xt') + call assert_equal("\"g/a\\/chist\t", @:) + " use as the 'wildchar' for completion set wildchar= call feedkeys(":g/a\\xb/clearj\\\"\", '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\\\"\", 'xt') call assert_equal('"e \~Xtest', @:) call delete('~Xtest') endif call feedkeys(":py3f\\\"\", '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\\\"\", '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\*\\\"\", 'xt') + call assert_equal('"e Xx\*Yy', @:) + call delete('Xx*Yy') endif call feedkeys(":py3f\\\"\", 'xt') *************** *** 1097,1102 **** --- 1114,1123 ---- call feedkeys(":e xt\\\"\", 'xt') call assert_equal('"e XTEST', @:) call assert_equal(['XTEST'], getcompletion('xt', 'file')) + let g:Sline = '' + call feedkeys(":e xt\\\\"\", '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(":'\", '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(":'\", '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\\\"\", 'xt') + call assert_equal('"e XTESTfoo', @:) + call feedkeys(":e Xt\\\"\", 'xt') + call assert_equal('"e Xtestbar', @:) + set fileignorecase + call feedkeys(":e XT\\\"\", 'xt') + call assert_equal('"e Xtest', @:) + call feedkeys(":e Xt\\\"\", '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\\\"\", 'xt') + catch /^Vim:Interrupt$/ + let interrupted = 1 + endtry + call assert_equal(1, interrupted) + delcommand Tcmd delfunc F set wildmode& *************** *** 2336,2339 **** --- 2385,2431 ---- cunmap endfunc + " Test for completion after a :substitute command followed by a pipe (|) + " character + func Test_cmdline_complete_substitute() + call feedkeys(":s | \t\\"\", 'xt') + call assert_equal("\"s | \t", @:) + call feedkeys(":s/ | \t\\"\", 'xt') + call assert_equal("\"s/ | \t", @:) + call feedkeys(":s/one | \t\\"\", 'xt') + call assert_equal("\"s/one | \t", @:) + call feedkeys(":s/one/ | \t\\"\", 'xt') + call assert_equal("\"s/one/ | \t", @:) + call feedkeys(":s/one/two | \t\\"\", 'xt') + call assert_equal("\"s/one/two | \t", @:) + call feedkeys(":s/one/two/ | chist\t\\"\", 'xt') + call assert_equal('"s/one/two/ | chistory', @:) + call feedkeys(":s/one/two/g \t\\"\", 'xt') + call assert_equal("\"s/one/two/g \t", @:) + call feedkeys(":s/one/two/g | chist\t\\"\", 'xt') + call assert_equal("\"s/one/two/g | chistory", @:) + call feedkeys(":s/one/t\\/ | \t\\"\", 'xt') + call assert_equal("\"s/one/t\\/ | \t", @:) + call feedkeys(":s/one/t\"o/ | chist\t\\"\", 'xt') + call assert_equal('"s/one/t"o/ | chistory', @:) + call feedkeys(":s/one/t|o/ | chist\t\\"\", 'xt') + call assert_equal('"s/one/t|o/ | chistory', @:) + call feedkeys(":&\t\\"\", 'xt') + call assert_equal("\"&\t", @:) + endfunc + + " Test for the :dlist command completion + func Test_cmdline_complete_dlist() + call feedkeys(":dlist 10 /pat/ a\\\"\", 'xt') + call assert_equal("\"dlist 10 /pat/ a\", @:) + call feedkeys(":dlist 10 /pat/ \t\\"\", 'xt') + call assert_equal("\"dlist 10 /pat/ \t", @:) + call feedkeys(":dlist 10 /pa\\t/\t\\"\", 'xt') + call assert_equal("\"dlist 10 /pa\\t/\t", @:) + call feedkeys(":dlist 10 /pat\\\t\\"\", 'xt') + call assert_equal("\"dlist 10 /pat\\\t", @:) + call feedkeys(":dlist 10 /pat/ | chist\\\"\", '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 -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///