Skip to content

Commit 72defda

Browse files
committed
patch 7.4.1119
Problem: argidx() has a wrong value after ":%argdelete". (Yegappan Lakshmanan) Solution: Correct the value of w_arg_idx. Add a test.
1 parent a99b904 commit 72defda

4 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/ex_cmds2.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,6 +2562,10 @@ ex_argdelete(eap)
25622562
curwin->w_arg_idx -= n;
25632563
else if (curwin->w_arg_idx > eap->line1)
25642564
curwin->w_arg_idx = eap->line1;
2565+
if (ARGCOUNT == 0)
2566+
curwin->w_arg_idx = 0;
2567+
else if (curwin->w_arg_idx >= ARGCOUNT)
2568+
curwin->w_arg_idx = ARGCOUNT - 1;
25652569
}
25662570
}
25672571
else if (*eap->arg == NUL)

src/testdir/Make_all.mak

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ SCRIPTS_GUI = test16.out
171171

172172
# Tests using runtest.vim.vim.
173173
# Keep test_alot.res as the last one, sort the others.
174-
NEW_TESTS = test_assert.res \
174+
NEW_TESTS = test_arglist.res \
175+
test_assert.res \
175176
test_cdo.res \
176177
test_hardcopy.res \
177178
test_increment.res \

src/testdir/test_arglist.vim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
" Test argument list commands
2+
3+
func Test_argidx()
4+
args a b c
5+
last
6+
call assert_equal(2, argidx())
7+
%argdelete
8+
call assert_equal(0, argidx())
9+
10+
args a b c
11+
call assert_equal(0, argidx())
12+
next
13+
call assert_equal(1, argidx())
14+
next
15+
call assert_equal(2, argidx())
16+
1argdelete
17+
call assert_equal(1, argidx())
18+
1argdelete
19+
call assert_equal(0, argidx())
20+
1argdelete
21+
call assert_equal(0, argidx())
22+
endfunc

src/version.c

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

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
1119,
744746
/**/
745747
1118,
746748
/**/

0 commit comments

Comments
 (0)