]> granicus.if.org Git - vim/commitdiff
patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented v8.2.1472
authorBram Moolenaar <Bram@vim.org>
Mon, 17 Aug 2020 17:34:10 +0000 (19:34 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 17 Aug 2020 17:34:10 +0000 (19:34 +0200)
Problem:    ":argdel" does not work like ":.argdel" as documented. (Alexey
            Demin)
Solution:   Make ":argdel" work like ":.argdel". (closes #6727)
            Also fix giving the error "0 more files to edit".

src/arglist.c
src/ex_docmd.c
src/testdir/test_arglist.vim
src/version.c

index 8e0f4d2e8e07ad1e9c44ca19c33da956cb743cf4..1810367606bf8d04400e129bc2bc2b044c7f2bfa 100644 (file)
@@ -776,10 +776,20 @@ ex_argdelete(exarg_T *eap)
     int                i;
     int                n;
 
-    if (eap->addr_count > 0)
+    if (eap->addr_count > 0 || *eap->arg == NUL)
     {
-       // ":1,4argdel": Delete all arguments in the range.
-       if (eap->line2 > ARGCOUNT)
+       // ":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;
        n = eap->line2 - eap->line1 + 1;
        if (*eap->arg != NUL)
@@ -808,8 +818,6 @@ 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, FALSE);
 #ifdef FEAT_TITLE
index c08524fff4950a69ba2fb9610d858145ac99b94e..612d478e9779bcf3cedfe8692cdf375463930e54 100644 (file)
@@ -5022,7 +5022,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)
        {
index 820d8b9695f7b02ca65b0934000796e76c092fa8..9b23a512e12c5deaaa8d4978f8228d3a1a247ae9 100644 (file)
@@ -423,9 +423,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()
index 7e660d8c40cc67e5f94bb2c7dfa57409b978c220..92649a3ec52155d03809ffd7fb6e867d9c600e5f 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1472,
 /**/
     1471,
 /**/