From 56bf026deac8eddb1abc8e1d46fde992cfc67ac2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 1 Sep 2022 20:25:34 +0800 Subject: vim-patch:9.0.0346: :horizontal modifier not fully supported Problem: :horizontal modifier not fully supported. Solution: Also use :horizontal for completion and user commands. (closes vim/vim#11025) https://github.com/vim/vim/commit/d3de178e5352fedf0f30b979f46a2fcbca24ea40 --- src/nvim/testdir/test_usercommands.vim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nvim/testdir/test_usercommands.vim') diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim index e37fe43b22..1065dd16e2 100644 --- a/src/nvim/testdir/test_usercommands.vim +++ b/src/nvim/testdir/test_usercommands.vim @@ -101,6 +101,10 @@ function Test_cmdmods() call assert_equal('vertical', g:mods) vert MyCmd call assert_equal('vertical', g:mods) + horizontal MyCmd + call assert_equal('horizontal', g:mods) + hor MyCmd + call assert_equal('horizontal', g:mods) aboveleft belowright botright browse confirm hide keepalt keepjumps \ keepmarks keeppatterns lockmarks noautocmd noswapfile silent -- cgit From 4d896be681d9b93ebe34cce38a5e787cd0332261 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 18 Oct 2022 20:46:42 +0800 Subject: vim-patch:9.0.0786: user command does not get number from :tab modifier (#20716) Problem: User command does not get number from :tab modifier. Solution: Include the number. (closes vim/vim#11393, closes vim/vim#6901) https://github.com/vim/vim/commit/208567e9d744ef7b89bed1f62e951ae4ee2f6f5f --- src/nvim/testdir/test_usercommands.vim | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/nvim/testdir/test_usercommands.vim') diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim index 1065dd16e2..12fe39851d 100644 --- a/src/nvim/testdir/test_usercommands.vim +++ b/src/nvim/testdir/test_usercommands.vim @@ -79,6 +79,19 @@ function Test_cmdmods() call assert_equal('silent!', g:mods) tab MyCmd call assert_equal('tab', g:mods) + 0tab MyCmd + call assert_equal('0tab', g:mods) + tab split + tab MyCmd + call assert_equal('tab', g:mods) + 1tab MyCmd + call assert_equal('1tab', g:mods) + tabprev + tab MyCmd + call assert_equal('tab', g:mods) + 2tab MyCmd + call assert_equal('2tab', g:mods) + 2tabclose topleft MyCmd call assert_equal('topleft', g:mods) to MyCmd -- cgit From 7b39ce36a4599539cd5cb07dad6bd980d30a3180 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 26 Oct 2022 13:41:43 +0800 Subject: vim-patch:8.2.0418: code in eval.c not sufficiently covered by tests Problem: Code in eval.c not sufficiently covered by tests. Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#5815) https://github.com/vim/vim/commit/8b633135106dda8605463b780573c45b00c22afe Nvim does not have v:none, so comment out test for it. --- src/nvim/testdir/test_usercommands.vim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/nvim/testdir/test_usercommands.vim') diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim index 12fe39851d..a3070d6517 100644 --- a/src/nvim/testdir/test_usercommands.vim +++ b/src/nvim/testdir/test_usercommands.vim @@ -617,6 +617,27 @@ func Test_command_list() call assert_equal("\nNo user-defined commands found", execute('command')) endfunc +" Test for a custom user completion returning the wrong value type +func Test_usercmd_custom() + func T1(a, c, p) + return "a\nb\n" + endfunc + command -nargs=* -complete=customlist,T1 TCmd1 + call feedkeys(":T1 \\\"\", 'xt') + call assert_equal('"T1 ', @:) + delcommand TCmd1 + delfunc T1 + + func T2(a, c, p) + return ['a', 'b', 'c'] + endfunc + command -nargs=* -complete=customlist,T2 TCmd2 + call feedkeys(":T2 \\\"\", 'xt') + call assert_equal('"T2 ', @:) + delcommand TCmd2 + delfunc T2 +endfunc + func Test_delcommand_buffer() command Global echo 'global' command -buffer OneBuffer echo 'one' -- cgit From ef363ed37cdf5c460cca840aebc825011e0294ee Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 26 Oct 2022 19:53:54 +0800 Subject: vim-patch:8.2.0619: null dict is not handled like an empty dict Problem: Null dict is not handled like an empty dict. Solution: Fix the code and add tests. (Yegappan Lakshmanan, closes vim/vim#5968) https://github.com/vim/vim/commit/ea04a6e8baff2f27da7cdd54bf70a5525994f76d Nvim doesn't support modifying NULL list, so comment out a line. --- src/nvim/testdir/test_usercommands.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/testdir/test_usercommands.vim') diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim index a3070d6517..5b8b384bae 100644 --- a/src/nvim/testdir/test_usercommands.vim +++ b/src/nvim/testdir/test_usercommands.vim @@ -623,17 +623,17 @@ func Test_usercmd_custom() return "a\nb\n" endfunc command -nargs=* -complete=customlist,T1 TCmd1 - call feedkeys(":T1 \\\"\", 'xt') - call assert_equal('"T1 ', @:) + call feedkeys(":TCmd1 \\\"\", 'xt') + call assert_equal('"TCmd1 ', @:) delcommand TCmd1 delfunc T1 func T2(a, c, p) - return ['a', 'b', 'c'] + return {} endfunc command -nargs=* -complete=customlist,T2 TCmd2 - call feedkeys(":T2 \\\"\", 'xt') - call assert_equal('"T2 ', @:) + call feedkeys(":TCmd2 \\\"\", 'xt') + call assert_equal('"TCmd2 ', @:) delcommand TCmd2 delfunc T2 endfunc -- cgit From 41282259ba0d0e4ae97caa4c6e77095b1d935e80 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 9 Dec 2022 06:12:13 +0800 Subject: vim-patch:8.2.4366: not enough tests for command line completion Problem: Not enough tests for command line completion. Solution: Add a few more tests. (Yegappan Lakshmanan, closes vim/vim#9760) https://github.com/vim/vim/commit/4d03d870007c593bce2cfa8d0a6597ca3a20fa35 Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_usercommands.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/nvim/testdir/test_usercommands.vim') diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim index 5b8b384bae..522be0fd61 100644 --- a/src/nvim/testdir/test_usercommands.vim +++ b/src/nvim/testdir/test_usercommands.vim @@ -400,6 +400,17 @@ func Test_CmdCompletion() com! -nargs=? -complete=custom,min DoCmd call assert_fails("call feedkeys(':DoCmd \t', 'tx')", 'E118:') + " custom completion for a pattern with a backslash + let g:ArgLead = '' + func! CustCompl(A, L, P) + let g:ArgLead = a:A + return ['one', 'two', 'three'] + endfunc + com! -nargs=? -complete=customlist,CustCompl DoCmd + call feedkeys(":DoCmd a\\\t", 'xt') + call assert_equal('a\', g:ArgLead) + delfunc CustCompl + delcom DoCmd endfunc -- cgit From 98dc445767875acd0e1d24ee5c864c18247be29f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 9 Dec 2022 06:15:03 +0800 Subject: vim-patch:8.2.4376: not enough tests for command line completion Problem: Not enough tests for command line completion. Solution: Add a few more tests. (Yegappan Lakshmanan, closes vim/vim#9771) https://github.com/vim/vim/commit/9773db6f9bce7a6f063e23179976d7825ace4d72 Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_usercommands.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_usercommands.vim') diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim index 522be0fd61..6a985d78aa 100644 --- a/src/nvim/testdir/test_usercommands.vim +++ b/src/nvim/testdir/test_usercommands.vim @@ -330,7 +330,7 @@ func CustomComplete(A, L, P) endfunc func CustomCompleteList(A, L, P) - return [ "Monday", "Tuesday", "Wednesday", {}] + return [ "Monday", "Tuesday", "Wednesday", {}, v:_null_string] endfunc func Test_CmdCompletion() -- cgit From ff62d761938e72129f6ba7ed2c2d56455444ebe7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 20 Dec 2022 05:24:03 +0800 Subject: vim-patch:9.0.1079: leaking memory when defining a user command fails Problem: Leaking memory when defining a user command fails. Solution: Free "compl_arg" when needed. (closes vim/vim#11726) https://github.com/vim/vim/commit/33e543038b84af7557ab9ecff500fc4ab98dd2a3 --- src/nvim/testdir/test_usercommands.vim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/nvim/testdir/test_usercommands.vim') diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim index 6a985d78aa..3ae990e022 100644 --- a/src/nvim/testdir/test_usercommands.vim +++ b/src/nvim/testdir/test_usercommands.vim @@ -323,6 +323,11 @@ func Test_CmdErrors() call assert_fails('com DoCmd :', 'E174:') comclear call assert_fails('delcom DoCmd', 'E184:') + + " These used to leak memory + call assert_fails('com! -complete=custom,CustomComplete _ :', 'E182:') + call assert_fails('com! -complete=custom,CustomComplete docmd :', 'E183:') + call assert_fails('com! -complete=custom,CustomComplete -xxx DoCmd :', 'E181:') endfunc func CustomComplete(A, L, P) -- cgit From 8b86cb8f5b26699ead075cb6660c9236dfb5c495 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 14 Jan 2023 23:44:38 +0800 Subject: vim-patch:8.2.4406: expand functions use confusing argument names (#21800) Problem: Expand functions use confusing argument names. Solution: Rename "file" to "match". Refactor some completion code. Add a few more tests. (Yegappan Lakshmanan, closes vim/vim#9790) https://github.com/vim/vim/commit/24384308635f40b15d399fbd4e60c25d5e21ed8d Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_usercommands.vim | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/nvim/testdir/test_usercommands.vim') diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim index 3ae990e022..6910361345 100644 --- a/src/nvim/testdir/test_usercommands.vim +++ b/src/nvim/testdir/test_usercommands.vim @@ -354,6 +354,14 @@ func Test_CmdCompletion() call feedkeys(":com -complete=co\\\"\", 'tx') call assert_equal('"com -complete=color command compiler', @:) + " try completion for unsupported argument values + call feedkeys(":com -newarg=\\\"\", 'tx') + call assert_equal("\"com -newarg=\t", @:) + + " command completion after the name in a user defined command + call feedkeys(":com MyCmd chist\\\"\", 'tx') + call assert_equal("\"com MyCmd chistory", @:) + command! DoCmd1 : command! DoCmd2 : call feedkeys(":com \\\"\", 'tx') @@ -365,6 +373,10 @@ func Test_CmdCompletion() call feedkeys(":delcom DoC\\\"\", 'tx') call assert_equal('"delcom DoCmd1 DoCmd2', @:) + " try argument completion for a command without completion + call feedkeys(":DoCmd1 \\\"\", 'tx') + call assert_equal("\"DoCmd1 \t", @:) + delcom DoCmd1 call feedkeys(":delcom DoC\\\"\", 'tx') call assert_equal('"delcom DoCmd2', @:) @@ -383,6 +395,21 @@ func Test_CmdCompletion() call feedkeys(":DoCmd \\\"\", 'tx') call assert_equal('"DoCmd mswin xterm', @:) + " Test for file name completion + com! -nargs=1 -complete=file DoCmd : + call feedkeys(":DoCmd READM\\\"\", 'tx') + call assert_equal('"DoCmd README.txt', @:) + + " Test for buffer name completion + com! -nargs=1 -complete=buffer DoCmd : + let bnum = bufadd('BufForUserCmd') + call setbufvar(bnum, '&buflisted', 1) + call feedkeys(":DoCmd BufFor\\\"\", 'tx') + call assert_equal('"DoCmd BufForUserCmd', @:) + bwipe BufForUserCmd + call feedkeys(":DoCmd BufFor\\\"\", 'tx') + call assert_equal('"DoCmd BufFor', @:) + com! -nargs=* -complete=custom,CustomComplete DoCmd : call feedkeys(":DoCmd \\\"\", 'tx') call assert_equal('"DoCmd January February Mars', @:) @@ -694,5 +721,30 @@ func Test_recursive_define() endwhile endfunc +" Test for using buffer-local ambiguous user-defined commands +func Test_buflocal_ambiguous_usercmd() + new + command -buffer -nargs=1 -complete=sign TestCmd1 echo "Hello" + command -buffer -nargs=1 -complete=sign TestCmd2 echo "World" + + call assert_fails("call feedkeys(':TestCmd\', 'xt')", 'E464:') + call feedkeys(":TestCmd \\\"\", 'xt') + call assert_equal('"TestCmd ', @:) + + delcommand TestCmd1 + delcommand TestCmd2 + bw! +endfunc + +" Test for using a multibyte character in a user command +func Test_multibyte_in_usercmd() + command SubJapanesePeriodToDot exe "%s/\u3002/./g" + new + call setline(1, "Hello\u3002") + SubJapanesePeriodToDot + call assert_equal('Hello.', getline(1)) + bw! + delcommand SubJapanesePeriodToDot +endfunc " vim: shiftwidth=2 sts=2 expandtab -- cgit