Skip to content

Commit 69a92fb

Browse files
committed
patch 8.0.0439: ":%argdel" gives an error for an empty arglist
Problem: Using ":%argdel" while the argument list is already empty gives an error. (Pavol Juhas) Solution: Don't give an error. (closes #1546)
1 parent 056f700 commit 69a92fb

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/ex_cmds2.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2832,8 +2832,15 @@ ex_argdelete(exarg_T *eap)
28322832
if (eap->line2 > ARGCOUNT)
28332833
eap->line2 = ARGCOUNT;
28342834
n = eap->line2 - eap->line1 + 1;
2835-
if (*eap->arg != NUL || n <= 0)
2835+
if (*eap->arg != NUL)
2836+
/* Can't have both a range and an argument. */
28362837
EMSG(_(e_invarg));
2838+
else if (n <= 0)
2839+
{
2840+
/* Don't give an error for ":%argdel" if the list is empty. */
2841+
if (eap->line1 != 1 || eap->line2 != 0)
2842+
EMSG(_(e_invrange));
2843+
}
28372844
else
28382845
{
28392846
for (i = eap->line1; i <= eap->line2; ++i)

src/testdir/test_arglist.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ func Test_argidx()
66
call assert_equal(2, argidx())
77
%argdelete
88
call assert_equal(0, argidx())
9+
" doing it again doesn't result in an error
10+
%argdelete
11+
call assert_equal(0, argidx())
12+
call assert_fails('2argdelete', 'E16:')
913

1014
args a b c
1115
call assert_equal(0, argidx())

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
439,
767769
/**/
768770
438,
769771
/**/

0 commit comments

Comments
 (0)