aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-08-03 00:57:38 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-08-08 22:29:55 -0400
commit292148b08b56476af0dc688e8a82df7d8e33f699 (patch)
tree77b1224ff6ed6066b3b867085e694071dc4e0b03 /src
parent43a874ab7441a4a0ab6e973f4fd7add394ed6dd9 (diff)
downloadrneovim-292148b08b56476af0dc688e8a82df7d8e33f699.tar.gz
rneovim-292148b08b56476af0dc688e8a82df7d8e33f699.tar.bz2
rneovim-292148b08b56476af0dc688e8a82df7d8e33f699.zip
vim-patch:8.2.3141: no error when using :complete for :command without -nargs
Problem: No error when using :complete for :command without -nargs. Solution: Give an error. (Martin Tournoij, closes vim/vim#8544, closes vim/vim#8541) https://github.com/vim/vim/commit/de69a7353e9bec552e15dbe3706a9f4e88080fce N/A patches for version.c: vim-patch:8.1.1801: cannot build without the +eval feature Problem: Cannot build without the +eval feature. Solution: Always define funcexe_T. https://github.com/vim/vim/commit/505e43a20eb25674b18d73971fe3b51dad917f9a vim-patch:8.1.1818: unused variable Problem: Unused variable. Solution: Remove the variable. (Mike Williams) https://github.com/vim/vim/commit/b4a88a0441a65a0c9411c294825a08ca703f541e vim-patch:8.2.1464: Vim9: build warning for unused variable Problem: Vim9: build warning for unused variable. Solution: Delete the variable declaration. https://github.com/vim/vim/commit/829ac868b7615d73dbfb536f7fcd44fc7c5b7c1d vim-patch:8.2.2639: build failure when fsync() is not available Problem: Build failure when fsync() is not available. Solution: Add #ifdef. https://github.com/vim/vim/commit/5ea79a2599d35f75e1ae8a75d2711c754c4cb7c4 vim-patch:8.2.2814: Vim9: unused variable Problem: Vim9: unused variable. (John Marriott) Solution: Adjust #ifdef. https://github.com/vim/vim/commit/b06b50dfa06e1cbefd634e2735e7cd5ddd5b911c vim-patch:8.2.2947: build failure without the channel feature Problem: Build failure without the channel feature. Solution: Add back #ifdef. (John Marriott) https://github.com/vim/vim/commit/f5bfa8faa7bbe025c10148d37e8b47217a430a3b vim-patch:8.2.2976: build failure without the +eval feature Problem: Build failure without the +eval feature. Solution: Add #ifdefs. https://github.com/vim/vim/commit/8de901e1f1b051e02a61ae76ad7c925e4c0642e5 vim-patch:8.2.2986: build failure without the profile feature Problem: Build failure without the profile feature. Solution: Add #ifdef. https://github.com/vim/vim/commit/d9f31c13d217b4b97f724774a67a6d1f8640e8ae vim-patch:8.2.3114: Amiga-like systems: build error using stat() Problem: Amiga-like systems: build error using stat(). Solution: Only build swapfile_process_running() on systems where it is actually used. (Ola Söder, closes vim/vim#8519) https://github.com/vim/vim/commit/599a6e5b3629d943a795cd69e4d3d19886f86405
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c7
-rw-r--r--src/nvim/testdir/test_usercommands.vim42
2 files changed, 30 insertions, 19 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index d10ecf5c7f..3afcd9ec5a 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -5514,6 +5514,9 @@ invalid_count:
return OK;
}
+static char e_complete_used_without_nargs[] = N_(
+ "E1208: -complete used without -nargs");
+
/*
* ":command ..."
*/
@@ -5565,10 +5568,10 @@ static void ex_command(exarg_T *eap)
uc_list(name, end - name);
} else if (!ASCII_ISUPPER(*name)) {
EMSG(_("E183: User defined commands must start with an uppercase letter"));
- return;
} else if (name_len <= 4 && STRNCMP(name, "Next", name_len) == 0) {
EMSG(_("E841: Reserved name, cannot be used for user defined command"));
- return;
+ } else if (compl > 0 && (argt & EX_EXTRA) == 0) {
+ EMSG(_(e_complete_used_without_nargs));
} else {
uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg,
addr_type_arg, eap->forceit);
diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim
index 4621207d19..29e578ac6d 100644
--- a/src/nvim/testdir/test_usercommands.vim
+++ b/src/nvim/testdir/test_usercommands.vim
@@ -238,6 +238,8 @@ func Test_CmdErrors()
call assert_fails('com! -complete=custom DoCmd :', 'E467:')
call assert_fails('com! -complete=customlist DoCmd :', 'E467:')
call assert_fails('com! -complete=behave,CustomComplete DoCmd :', 'E468:')
+ call assert_fails('com! -complete=file DoCmd :', 'E1208:')
+ call assert_fails('com! -nargs=0 -complete=file DoCmd :', 'E1208:')
call assert_fails('com! -nargs=x DoCmd :', 'E176:')
call assert_fails('com! -count=1 -count=2 DoCmd :', 'E177:')
call assert_fails('com! -count=x DoCmd :', 'E178:')
@@ -306,27 +308,33 @@ func Test_CmdCompletion()
call feedkeys(":com DoC\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com DoC', @:)
- com! -complete=behave DoCmd :
+ com! -nargs=1 -complete=behave DoCmd :
call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"DoCmd mswin xterm', @:)
- " This does not work. Why?
- "call feedkeys(":DoCmd x\<C-A>\<C-B>\"\<CR>", 'tx')
- "call assert_equal('"DoCmd xterm', @:)
-
- com! -complete=custom,CustomComplete DoCmd :
+ com! -nargs=* -complete=custom,CustomComplete DoCmd :
call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"DoCmd January February Mars', @:)
- com! -complete=customlist,CustomCompleteList DoCmd :
+ com! -nargs=? -complete=customlist,CustomCompleteList DoCmd :
call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"DoCmd Monday Tuesday Wednesday', @:)
- com! -complete=custom,CustomCompleteList DoCmd :
+ com! -nargs=+ -complete=custom,CustomCompleteList DoCmd :
call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E730:')
- com! -complete=customlist,CustomComp DoCmd :
+ com! -nargs=+ -complete=customlist,CustomComp DoCmd :
call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E117:')
+
+ " custom completion without a function
+ com! -nargs=? -complete=custom, DoCmd
+ call assert_beeps("call feedkeys(':DoCmd \t', 'tx')")
+
+ " custom completion failure with the wrong function
+ com! -nargs=? -complete=custom,min DoCmd
+ call assert_fails("call feedkeys(':DoCmd \t', 'tx')", 'E118:')
+
+ delcom DoCmd
endfunc
func CallExecute(A, L, P)
@@ -459,21 +467,21 @@ func Test_command_list()
\ execute('command DoCmd'))
" Test with various -complete= argument values (non-exhaustive list)
- command! -complete=arglist DoCmd :
+ command! -nargs=1 -complete=arglist DoCmd :
call assert_equal("\n Name Args Address Complete Definition"
- \ .. "\n DoCmd 0 arglist :",
+ \ .. "\n DoCmd 1 arglist :",
\ execute('command DoCmd'))
- command! -complete=augroup DoCmd :
+ command! -nargs=* -complete=augroup DoCmd :
call assert_equal("\n Name Args Address Complete Definition"
- \ .. "\n DoCmd 0 augroup :",
+ \ .. "\n DoCmd * augroup :",
\ execute('command DoCmd'))
- command! -complete=custom,CustomComplete DoCmd :
+ command! -nargs=? -complete=custom,CustomComplete DoCmd :
call assert_equal("\n Name Args Address Complete Definition"
- \ .. "\n DoCmd 0 custom :",
+ \ .. "\n DoCmd ? custom :",
\ execute('command DoCmd'))
- command! -complete=customlist,CustomComplete DoCmd :
+ command! -nargs=+ -complete=customlist,CustomComplete DoCmd :
call assert_equal("\n Name Args Address Complete Definition"
- \ .. "\n DoCmd 0 customlist :",
+ \ .. "\n DoCmd + customlist :",
\ execute('command DoCmd'))
" Test with various -narg= argument values.