]> granicus.if.org Git - vim/commitdiff
patch 7.4.1123 v7.4.1123
authorBram Moolenaar <Bram@vim.org>
Sun, 17 Jan 2016 18:39:00 +0000 (19:39 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 17 Jan 2016 18:39:00 +0000 (19:39 +0100)
Problem:    Using ":argadd" when there are no arguments results in the second
            argument to be the current one. (Yegappan Lakshmanan)
Solution:   Correct the w_arg_idx value.

src/ex_cmds2.c
src/testdir/test_arglist.vim
src/version.c

index 012a1af222bd430d1dfe24bf5a47706f090273b9..59bf945894a073671586806f6336c52850923f59 100644 (file)
@@ -2836,6 +2836,7 @@ alist_add_list(count, files, after)
     int                after;      /* where to add: 0 = before first one */
 {
     int                i;
+    int                old_argcount = ARGCOUNT;
 
     if (ga_grow(&ALIST(curwin)->al_ga, count) == OK)
     {
@@ -2852,8 +2853,8 @@ alist_add_list(count, files, after)
            ARGLIST[after + i].ae_fnum = buflist_add(files[i], BLN_LISTED);
        }
        ALIST(curwin)->al_ga.ga_len += count;
-       if (curwin->w_arg_idx >= after)
-           ++curwin->w_arg_idx;
+       if (old_argcount > 0 && curwin->w_arg_idx >= after)
+           curwin->w_arg_idx += count;
        return after;
     }
 
index 3f72f0ff9c5adb8a6e5f678488cfd0afa0d835b8..522631741a10450c2313228eeed03ee2a15b9e53 100644 (file)
@@ -20,3 +20,55 @@ func Test_argidx()
   1argdelete
   call assert_equal(0, argidx())
 endfunc
+
+func Test_argadd()
+  %argdelete
+  argadd a b c
+  call assert_equal(0, argidx())
+
+  %argdelete
+  argadd a
+  call assert_equal(0, argidx())
+  argadd b c d
+  call assert_equal(0, argidx())
+
+  call Init_abc()
+  argadd x
+  call Assert_argc(['a', 'b', 'x', 'c'])
+  call assert_equal(1, argidx())
+
+  call Init_abc()
+  0argadd x
+  call Assert_argc(['x', 'a', 'b', 'c'])
+  call assert_equal(2, argidx())
+
+  call Init_abc()
+  1argadd x
+  call Assert_argc(['a', 'x', 'b', 'c'])
+  call assert_equal(2, argidx())
+
+  call Init_abc()
+  $argadd x
+  call Assert_argc(['a', 'b', 'c', 'x'])
+  call assert_equal(1, argidx())
+
+  call Init_abc()
+  $argadd x
+  +2argadd y
+  call Assert_argc(['a', 'b', 'c', 'x', 'y'])
+  call assert_equal(1, argidx())
+endfunc
+
+func Init_abc()
+  args a b c
+  next
+endfunc
+
+func Assert_argc(l)
+  call assert_equal(len(a:l), argc())
+  let i = 0
+  while i < len(a:l) && i < argc()
+    call assert_equal(a:l[i], argv(i))
+    let i += 1
+  endwhile
+endfunc
index 76e176a888fe002dca2e9dc8f75a30d8855efce7..09176eb547988d6de162d87f910163bb928951f0 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1123,
 /**/
     1122,
 /**/