Skip to content

Commit a237ef0

Browse files
committed
updated for version 7.4.646
Problem: ":bufdo" may start at a deleted buffer. Solution: Find the first not deleted buffer. (Shane Harper)
1 parent c98de09 commit a237ef0

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

src/ex_cmds2.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,7 @@ ex_listdo(eap)
24402440
win_T *wp;
24412441
tabpage_T *tp;
24422442
#endif
2443-
buf_T *buf;
2443+
buf_T *buf = curbuf;
24442444
int next_fnum = 0;
24452445
#if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
24462446
char_u *save_ei = NULL;
@@ -2493,20 +2493,28 @@ ex_listdo(eap)
24932493
case CMD_argdo:
24942494
i = eap->line1 - 1;
24952495
break;
2496-
case CMD_bufdo:
2497-
i = eap->line1;
2498-
break;
24992496
default:
25002497
break;
25012498
}
25022499
/* set pcmark now */
25032500
if (eap->cmdidx == CMD_bufdo)
2504-
goto_buffer(eap, DOBUF_FIRST, FORWARD, i);
2501+
{
2502+
/* Advance to the first listed buffer after "eap->line1". */
2503+
for (buf = firstbuf; buf != NULL && (buf->b_fnum < eap->line1
2504+
|| !buf->b_p_bl); buf = buf->b_next)
2505+
if (buf->b_fnum > eap->line2)
2506+
{
2507+
buf = NULL;
2508+
break;
2509+
}
2510+
if (buf != NULL)
2511+
goto_buffer(eap, DOBUF_FIRST, FORWARD, buf->b_fnum);
2512+
}
25052513
else
25062514
setpcmark();
25072515
listcmd_busy = TRUE; /* avoids setting pcmark below */
25082516

2509-
while (!got_int)
2517+
while (!got_int && buf != NULL)
25102518
{
25112519
if (eap->cmdidx == CMD_argdo)
25122520
{

src/testdir/test_command_count.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ STARTTEST
141141
:let buffers = ''
142142
:.,$-bufdo let buffers .= ' '.bufnr('%')
143143
:call add(g:lines, 'bufdo:' . buffers)
144+
:3bd
144145
:let buffers = ''
145146
:3,7bufdo let buffers .= ' '.bufnr('%')
146147
:call add(g:lines, 'bufdo:' . buffers)

src/testdir/test_command_count.ok

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ aaa: 0 bbb: 0 ccc: 0
3434
argdo: c d e
3535
windo: 2 3 4
3636
bufdo: 2 3 4 5 6 7 8 9 10 15
37-
bufdo: 3 4 5 6 7
37+
bufdo: 4 5 6 7
3838
tabdo: 2 3 4

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+
646,
744746
/**/
745747
645,
746748
/**/

0 commit comments

Comments
 (0)