@@ -2445,10 +2445,10 @@ buf_write_all(buf_T *buf, int forceit)
24452445 */
24462446
24472447static char_u * do_one_arg (char_u * str );
2448- static int do_arglist (char_u * str , int what , int after );
2448+ static int do_arglist (char_u * str , int what , int after , int will_edit );
24492449static void alist_check_arg_idx (void );
24502450static int editing_arg_idx (win_T * win );
2451- static int alist_add_list (int count , char_u * * files , int after );
2451+ static void alist_add_list (int count , char_u * * files , int after , int will_edit );
24522452#define AL_SET 1
24532453#define AL_ADD 2
24542454#define AL_DEL 3
@@ -2553,7 +2553,7 @@ get_arglist_exp(
25532553 void
25542554set_arglist (char_u * str )
25552555{
2556- do_arglist (str , AL_SET , 0 );
2556+ do_arglist (str , AL_SET , 0 , FALSE );
25572557}
25582558
25592559/*
@@ -2567,7 +2567,8 @@ set_arglist(char_u *str)
25672567do_arglist (
25682568 char_u * str ,
25692569 int what ,
2570- int after UNUSED ) /* 0 means before first one */
2570+ int after UNUSED , // 0 means before first one
2571+ int will_edit ) // will edit added argument
25712572{
25722573 garray_T new_ga ;
25732574 int exp_count ;
@@ -2652,11 +2653,11 @@ do_arglist(
26522653
26532654 if (what == AL_ADD )
26542655 {
2655- ( void ) alist_add_list (exp_count , exp_files , after );
2656+ alist_add_list (exp_count , exp_files , after , will_edit );
26562657 vim_free (exp_files );
26572658 }
26582659 else /* what == AL_SET */
2659- alist_set (ALIST (curwin ), exp_count , exp_files , FALSE , NULL , 0 );
2660+ alist_set (ALIST (curwin ), exp_count , exp_files , will_edit , NULL , 0 );
26602661 }
26612662
26622663 alist_check_arg_idx ();
@@ -2932,7 +2933,7 @@ ex_next(exarg_T *eap)
29322933 {
29332934 if (* eap -> arg != NUL ) /* redefine file list */
29342935 {
2935- if (do_arglist (eap -> arg , AL_SET , 0 ) == FAIL )
2936+ if (do_arglist (eap -> arg , AL_SET , 0 , TRUE ) == FAIL )
29362937 return ;
29372938 i = 0 ;
29382939 }
@@ -2952,7 +2953,7 @@ ex_argedit(exarg_T *eap)
29522953 // Whether curbuf will be reused, curbuf->b_ffname will be set.
29532954 int curbuf_is_reusable = curbuf_reusable ();
29542955
2955- if (do_arglist (eap -> arg , AL_ADD , i ) == FAIL )
2956+ if (do_arglist (eap -> arg , AL_ADD , i , TRUE ) == FAIL )
29562957 return ;
29572958#ifdef FEAT_TITLE
29582959 maketitle ();
@@ -2974,7 +2975,8 @@ ex_argedit(exarg_T *eap)
29742975ex_argadd (exarg_T * eap )
29752976{
29762977 do_arglist (eap -> arg , AL_ADD ,
2977- eap -> addr_count > 0 ? (int )eap -> line2 : curwin -> w_arg_idx + 1 );
2978+ eap -> addr_count > 0 ? (int )eap -> line2 : curwin -> w_arg_idx + 1 ,
2979+ FALSE);
29782980#ifdef FEAT_TITLE
29792981 maketitle ();
29802982#endif
@@ -3024,7 +3026,7 @@ ex_argdelete(exarg_T *eap)
30243026 else if (* eap -> arg == NUL )
30253027 EMSG (_ (e_argreq ));
30263028 else
3027- do_arglist (eap -> arg , AL_DEL , 0 );
3029+ do_arglist (eap -> arg , AL_DEL , 0 , FALSE );
30283030#ifdef FEAT_TITLE
30293031 maketitle ();
30303032#endif
@@ -3269,13 +3271,13 @@ ex_listdo(exarg_T *eap)
32693271 * Add files[count] to the arglist of the current window after arg "after".
32703272 * The file names in files[count] must have been allocated and are taken over.
32713273 * Files[] itself is not taken over.
3272- * Returns index of first added argument. Returns -1 when failed (out of mem).
32733274 */
3274- static int
3275+ static void
32753276alist_add_list (
32763277 int count ,
32773278 char_u * * files ,
3278- int after ) /* where to add: 0 = before first one */
3279+ int after , // where to add: 0 = before first one
3280+ int will_edit ) // will edit adding argument
32793281{
32803282 int i ;
32813283 int old_argcount = ARGCOUNT ;
@@ -3291,19 +3293,19 @@ alist_add_list(
32913293 (ARGCOUNT - after ) * sizeof (aentry_T ));
32923294 for (i = 0 ; i < count ; ++ i )
32933295 {
3296+ int flags = BLN_LISTED | (will_edit ? BLN_CURBUF : 0 );
3297+
32943298 ARGLIST [after + i ].ae_fname = files [i ];
3295- ARGLIST [after + i ].ae_fnum =
3296- buflist_add (files [i ], BLN_LISTED | BLN_CURBUF );
3299+ ARGLIST [after + i ].ae_fnum = buflist_add (files [i ], flags );
32973300 }
32983301 ALIST (curwin )-> al_ga .ga_len += count ;
32993302 if (old_argcount > 0 && curwin -> w_arg_idx >= after )
33003303 curwin -> w_arg_idx += count ;
3301- return after ;
3304+ return ;
33023305 }
33033306
33043307 for (i = 0 ; i < count ; ++ i )
33053308 vim_free (files [i ]);
3306- return -1 ;
33073309}
33083310
33093311#if defined(FEAT_CMDL_COMPL ) || defined(PROTO )
0 commit comments