From 45615cedd10fb5dc3c502815ed4d98b6d4e4488a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 17 Aug 2020 18:43:40 -0400 Subject: vim-patch:8.2.1472: ":argdel" does not work like ":.argdel" as documented Problem: ":argdel" does not work like ":.argdel" as documented. (Alexey Demin) Solution: Make ":argdel" work like ":.argdel". (closes vim/vim#6727) Also fix giving the error "0 more files to edit". https://github.com/vim/vim/commit/7b22117c4ecf383b6f35acef041773a83ec28220 --- src/nvim/ex_cmds2.c | 15 ++++++++++----- src/nvim/ex_docmd.c | 2 +- src/nvim/testdir/test_arglist.vim | 10 ++++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 7f4b01e306..7a06cb7ca6 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -1984,9 +1984,16 @@ void ex_argadd(exarg_T *eap) /// ":argdelete" void ex_argdelete(exarg_T *eap) { - if (eap->addr_count > 0) { - // ":1,4argdel": Delete all arguments in the range. - if (eap->line2 > ARGCOUNT) { + if (eap->addr_count > 0 || *eap->arg == NUL) { + // ":argdel" works like ":.argdel" + if (eap->addr_count == 0) { + if (curwin->w_arg_idx >= ARGCOUNT) { + EMSG(_("E610: No argument to delete")); + return; + } + eap->line1 = eap->line2 = curwin->w_arg_idx + 1; + } else if (eap->line2 > ARGCOUNT) { + // ":1,4argdel": Delete all arguments in the range. eap->line2 = ARGCOUNT; } linenr_T n = eap->line2 - eap->line1 + 1; @@ -2016,8 +2023,6 @@ void ex_argdelete(exarg_T *eap) curwin->w_arg_idx = ARGCOUNT - 1; } } - } else if (*eap->arg == NUL) { - EMSG(_(e_argreq)); } else { do_arglist(eap->arg, AL_DEL, 0); } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 064cebe016..1160ab835b 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -4949,7 +4949,7 @@ check_more( int n = ARGCOUNT - curwin->w_arg_idx - 1; if (!forceit && only_one_window() - && ARGCOUNT > 1 && !arg_had_last && n >= 0 && quitmore == 0) { + && ARGCOUNT > 1 && !arg_had_last && n > 0 && quitmore == 0) { if (message) { if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL) { char_u buff[DIALOG_MSG_SIZE]; diff --git a/src/nvim/testdir/test_arglist.vim b/src/nvim/testdir/test_arglist.vim index 6e7583ade3..92fedf9bfb 100644 --- a/src/nvim/testdir/test_arglist.vim +++ b/src/nvim/testdir/test_arglist.vim @@ -397,9 +397,15 @@ func Test_argdelete() last argdelete % call assert_equal(['b'], argv()) - call assert_fails('argdelete', 'E471:') + call assert_fails('argdelete', 'E610:') call assert_fails('1,100argdelete', 'E16:') - %argd + + call Reset_arglist() + args a b c d + next + argdel + call Assert_argc(['a', 'c', 'd']) + %argdel endfunc func Test_argdelete_completion() -- cgit