vim-patch:7.4.646 #2926

Problem:    ":bufdo" may start at a deleted buffer.
Solution:   Find the first not deleted buffer. (Shane Harper)

https://github.com/vim/vim/commit/v7-4-646
This commit is contained in:
Florian Walch 2015-06-29 16:35:37 +03:00
parent 1b78ad1c4d
commit e949c2bd62
4 changed files with 20 additions and 9 deletions

View File

@ -1862,20 +1862,30 @@ void ex_listdo(exarg_T *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;
} }
buf_T *buf = curbuf;
/* 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". */
else 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 {
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) {
/* go to argument "i" */ /* go to argument "i" */
if (i == ARGCOUNT) if (i == ARGCOUNT)

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

@ -163,7 +163,7 @@ static int included_patches[] = {
//649, //649,
//648 NA //648 NA
//647 NA //647 NA
//646, 646,
//645, //645,
//644 NA //644 NA
//643, //643,