0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

updated for version 7.4.646

Problem:    ":bufdo" may start at a deleted buffer.
Solution:   Find the first not deleted buffer. (Shane Harper)
This commit is contained in:
Bram Moolenaar 2015-02-27 20:33:37 +01:00
parent 8da9bbfd02
commit e25bb90b2e
4 changed files with 18 additions and 7 deletions

View File

@ -2440,7 +2440,7 @@ ex_listdo(eap)
win_T *wp; win_T *wp;
tabpage_T *tp; tabpage_T *tp;
#endif #endif
buf_T *buf; buf_T *buf = curbuf;
int next_fnum = 0; int next_fnum = 0;
#if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
char_u *save_ei = NULL; char_u *save_ei = NULL;
@ -2493,20 +2493,28 @@ ex_listdo(eap)
case CMD_argdo: case CMD_argdo:
i = eap->line1 - 1; i = eap->line1 - 1;
break; break;
case CMD_bufdo:
i = eap->line1;
break;
default: default:
break; break;
} }
/* set pcmark now */ /* set pcmark now */
if (eap->cmdidx == CMD_bufdo) if (eap->cmdidx == CMD_bufdo)
goto_buffer(eap, DOBUF_FIRST, FORWARD, i); {
/* Advance to the first listed buffer after "eap->line1". */
for (buf = firstbuf; buf != NULL && (buf->b_fnum < eap->line1
|| !buf->b_p_bl); buf = buf->b_next)
if (buf->b_fnum > eap->line2)
{
buf = NULL;
break;
}
if (buf != NULL)
goto_buffer(eap, DOBUF_FIRST, FORWARD, buf->b_fnum);
}
else else
setpcmark(); setpcmark();
listcmd_busy = TRUE; /* avoids setting pcmark below */ listcmd_busy = TRUE; /* avoids setting pcmark below */
while (!got_int) while (!got_int && buf != NULL)
{ {
if (eap->cmdidx == CMD_argdo) if (eap->cmdidx == CMD_argdo)
{ {

View File

@ -141,6 +141,7 @@ STARTTEST
:let buffers = '' :let buffers = ''
:.,$-bufdo let buffers .= ' '.bufnr('%') :.,$-bufdo let buffers .= ' '.bufnr('%')
:call add(g:lines, 'bufdo:' . buffers) :call add(g:lines, 'bufdo:' . buffers)
:3bd
:let buffers = '' :let buffers = ''
:3,7bufdo let buffers .= ' '.bufnr('%') :3,7bufdo let buffers .= ' '.bufnr('%')
:call add(g:lines, 'bufdo:' . buffers) :call add(g:lines, 'bufdo:' . buffers)

View File

@ -34,5 +34,5 @@ aaa: 0 bbb: 0 ccc: 0
argdo: c d e argdo: c d e
windo: 2 3 4 windo: 2 3 4
bufdo: 2 3 4 5 6 7 8 9 10 15 bufdo: 2 3 4 5 6 7 8 9 10 15
bufdo: 3 4 5 6 7 bufdo: 4 5 6 7
tabdo: 2 3 4 tabdo: 2 3 4

View File

@ -741,6 +741,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
646,
/**/ /**/
645, 645,
/**/ /**/