1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0341
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0341
Problem: :argadd in empty buffer changes the buffer name. (Pavol Juhas)
Solution: Don't re-use the current buffer when not going to edit the file.
(closes #3397) Do re-use the current buffer for :next.
Files: src/ex_cmds2.c, src/testdir/test_arglist.vim,
src/testdir/test_command_count.vim
*** ../vim-8.1.0340/src/ex_cmds2.c 2018-08-30 13:07:12.026033864 +0200
--- src/ex_cmds2.c 2018-08-31 23:00:26.400150737 +0200
***************
*** 2445,2454 ****
*/
static char_u *do_one_arg(char_u *str);
! static int do_arglist(char_u *str, int what, int after);
static void alist_check_arg_idx(void);
static int editing_arg_idx(win_T *win);
! static int alist_add_list(int count, char_u **files, int after);
#define AL_SET 1
#define AL_ADD 2
#define AL_DEL 3
--- 2445,2454 ----
*/
static char_u *do_one_arg(char_u *str);
! static int do_arglist(char_u *str, int what, int after, int will_edit);
static void alist_check_arg_idx(void);
static int editing_arg_idx(win_T *win);
! static void alist_add_list(int count, char_u **files, int after, int will_edit);
#define AL_SET 1
#define AL_ADD 2
#define AL_DEL 3
***************
*** 2553,2559 ****
void
set_arglist(char_u *str)
{
! do_arglist(str, AL_SET, 0);
}
/*
--- 2553,2559 ----
void
set_arglist(char_u *str)
{
! do_arglist(str, AL_SET, 0, FALSE);
}
/*
***************
*** 2567,2573 ****
do_arglist(
char_u *str,
int what,
! int after UNUSED) /* 0 means before first one */
{
garray_T new_ga;
int exp_count;
--- 2567,2574 ----
do_arglist(
char_u *str,
int what,
! int after UNUSED, // 0 means before first one
! int will_edit) // will edit added argument
{
garray_T new_ga;
int exp_count;
***************
*** 2652,2662 ****
if (what == AL_ADD)
{
! (void)alist_add_list(exp_count, exp_files, after);
vim_free(exp_files);
}
else /* what == AL_SET */
! alist_set(ALIST(curwin), exp_count, exp_files, FALSE, NULL, 0);
}
alist_check_arg_idx();
--- 2653,2663 ----
if (what == AL_ADD)
{
! alist_add_list(exp_count, exp_files, after, will_edit);
vim_free(exp_files);
}
else /* what == AL_SET */
! alist_set(ALIST(curwin), exp_count, exp_files, will_edit, NULL, 0);
}
alist_check_arg_idx();
***************
*** 2932,2938 ****
{
if (*eap->arg != NUL) /* redefine file list */
{
! if (do_arglist(eap->arg, AL_SET, 0) == FAIL)
return;
i = 0;
}
--- 2933,2939 ----
{
if (*eap->arg != NUL) /* redefine file list */
{
! if (do_arglist(eap->arg, AL_SET, 0, TRUE) == FAIL)
return;
i = 0;
}
***************
*** 2952,2958 ****
// Whether curbuf will be reused, curbuf->b_ffname will be set.
int curbuf_is_reusable = curbuf_reusable();
! if (do_arglist(eap->arg, AL_ADD, i) == FAIL)
return;
#ifdef FEAT_TITLE
maketitle();
--- 2953,2959 ----
// Whether curbuf will be reused, curbuf->b_ffname will be set.
int curbuf_is_reusable = curbuf_reusable();
! if (do_arglist(eap->arg, AL_ADD, i, TRUE) == FAIL)
return;
#ifdef FEAT_TITLE
maketitle();
***************
*** 2974,2980 ****
ex_argadd(exarg_T *eap)
{
do_arglist(eap->arg, AL_ADD,
! eap->addr_count > 0 ? (int)eap->line2 : curwin->w_arg_idx + 1);
#ifdef FEAT_TITLE
maketitle();
#endif
--- 2975,2982 ----
ex_argadd(exarg_T *eap)
{
do_arglist(eap->arg, AL_ADD,
! eap->addr_count > 0 ? (int)eap->line2 : curwin->w_arg_idx + 1,
! FALSE);
#ifdef FEAT_TITLE
maketitle();
#endif
***************
*** 3024,3030 ****
else if (*eap->arg == NUL)
EMSG(_(e_argreq));
else
! do_arglist(eap->arg, AL_DEL, 0);
#ifdef FEAT_TITLE
maketitle();
#endif
--- 3026,3032 ----
else if (*eap->arg == NUL)
EMSG(_(e_argreq));
else
! do_arglist(eap->arg, AL_DEL, 0, FALSE);
#ifdef FEAT_TITLE
maketitle();
#endif
***************
*** 3269,3281 ****
* Add files[count] to the arglist of the current window after arg "after".
* The file names in files[count] must have been allocated and are taken over.
* Files[] itself is not taken over.
- * Returns index of first added argument. Returns -1 when failed (out of mem).
*/
! static int
alist_add_list(
int count,
char_u **files,
! int after) /* where to add: 0 = before first one */
{
int i;
int old_argcount = ARGCOUNT;
--- 3271,3283 ----
* Add files[count] to the arglist of the current window after arg "after".
* The file names in files[count] must have been allocated and are taken over.
* Files[] itself is not taken over.
*/
! static void
alist_add_list(
int count,
char_u **files,
! int after, // where to add: 0 = before first one
! int will_edit) // will edit adding argument
{
int i;
int old_argcount = ARGCOUNT;
***************
*** 3291,3309 ****
(ARGCOUNT - after) * sizeof(aentry_T));
for (i = 0; i < count; ++i)
{
ARGLIST[after + i].ae_fname = files[i];
! ARGLIST[after + i].ae_fnum =
! buflist_add(files[i], BLN_LISTED | BLN_CURBUF);
}
ALIST(curwin)->al_ga.ga_len += count;
if (old_argcount > 0 && curwin->w_arg_idx >= after)
curwin->w_arg_idx += count;
! return after;
}
for (i = 0; i < count; ++i)
vim_free(files[i]);
- return -1;
}
#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
--- 3293,3311 ----
(ARGCOUNT - after) * sizeof(aentry_T));
for (i = 0; i < count; ++i)
{
+ int flags = BLN_LISTED | (will_edit ? BLN_CURBUF : 0);
+
ARGLIST[after + i].ae_fname = files[i];
! ARGLIST[after + i].ae_fnum = buflist_add(files[i], flags);
}
ALIST(curwin)->al_ga.ga_len += count;
if (old_argcount > 0 && curwin->w_arg_idx >= after)
curwin->w_arg_idx += count;
! return;
}
for (i = 0; i < count; ++i)
vim_free(files[i]);
}
#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
*** ../vim-8.1.0340/src/testdir/test_arglist.vim 2018-04-24 21:54:38.000000000 +0200
--- src/testdir/test_arglist.vim 2018-08-31 22:42:29.649222626 +0200
***************
*** 80,85 ****
--- 80,103 ----
call assert_equal(0, len(argv()))
endfunc
+ func Test_argadd_empty_curbuf()
+ new
+ let curbuf = bufnr('%')
+ call writefile(['test', 'Xargadd'], 'Xargadd')
+ " must not re-use the current buffer.
+ argadd Xargadd
+ call assert_equal(curbuf, bufnr('%'))
+ call assert_equal('', bufname('%'))
+ call assert_equal(1, line('$'))
+ rew
+ call assert_notequal(curbuf, bufnr('%'))
+ call assert_equal('Xargadd', bufname('%'))
+ call assert_equal(2, line('$'))
+
+ %argd
+ bwipe!
+ endfunc
+
func Init_abc()
args a b c
next
*** ../vim-8.1.0340/src/testdir/test_command_count.vim 2018-04-24 21:47:12.000000000 +0200
--- src/testdir/test_command_count.vim 2018-08-31 23:01:54.967036898 +0200
***************
*** 158,164 ****
func Test_command_count_4()
%argd
let bufnr = bufnr('$')
! arga aa bb cc dd ee ff
3argu
let args = []
.,$-argdo call add(args, expand('%'))
--- 158,166 ----
func Test_command_count_4()
%argd
let bufnr = bufnr('$')
! next aa bb cc dd ee ff
! call assert_equal(bufnr, bufnr('%'))
!
3argu
let args = []
.,$-argdo call add(args, expand('%'))
*** ../vim-8.1.0340/src/version.c 2018-08-31 22:26:49.210912007 +0200
--- src/version.c 2018-08-31 22:44:55.551715626 +0200
***************
*** 796,797 ****
--- 796,799 ----
{ /* Add new patch number below this line */
+ /**/
+ 341,
/**/
--
login: yes
password: I don't know, please tell me
password is incorrect
login: yes
password: incorrect
/// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///
|