Patch 7.4.1123
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.
Files:      src/ex_cmds2.c, src/testdir/test_arglist.vim


*** ../vim-7.4.1122/src/ex_cmds2.c      2016-01-17 18:04:15.412608602 +0100
--- src/ex_cmds2.c      2016-01-17 19:25:19.571909187 +0100
***************
*** 2836,2841 ****
--- 2836,2842 ----
      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,2859 ****
            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;
        return after;
      }
  
--- 2853,2860 ----
            ARGLIST[after + i].ae_fnum = buflist_add(files[i], BLN_LISTED);
        }
        ALIST(curwin)->al_ga.ga_len += count;
!       if (old_argcount > 0 && curwin->w_arg_idx >= after)
!           curwin->w_arg_idx += count;
        return after;
      }
  
*** ../vim-7.4.1122/src/testdir/test_arglist.vim        2016-01-17 
18:04:15.412608602 +0100
--- src/testdir/test_arglist.vim        2016-01-17 19:37:43.191856930 +0100
***************
*** 20,22 ****
--- 20,74 ----
    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
*** ../vim-7.4.1122/src/version.c       2016-01-17 18:49:41.839115718 +0100
--- src/version.c       2016-01-17 19:07:00.179832373 +0100
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     1123,
  /**/

-- 
For humans, honesty is a matter of degree.  Engineers are always honest in
matters of technology and human relationships.  That's why it's a good idea
to keep engineers away from customers, romantic interests, and other people
who can't handle the truth.
                                (Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui