diff options
author | Bram Moolenaar <Bram@vim.org> | 2015-02-27 20:33:37 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2015-02-27 20:33:37 +0100 |
commit | e25bb90b2eb0ceed2caa5202ca62003e367021ae (patch) | |
tree | 9f1b2ea8bfd1ba156af43f09fc33cd2c571e387c | |
parent | 8da9bbfd02957b79edd595c8c7397453012510b0 (diff) | |
download | vim-git-e25bb90b2eb0ceed2caa5202ca62003e367021ae.tar.gz |
updated for version 7.4.646v7.4.646
Problem: ":bufdo" may start at a deleted buffer.
Solution: Find the first not deleted buffer. (Shane Harper)
-rw-r--r-- | src/ex_cmds2.c | 20 | ||||
-rw-r--r-- | src/testdir/test_command_count.in | 1 | ||||
-rw-r--r-- | src/testdir/test_command_count.ok | 2 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 18 insertions, 7 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 48badeb93..2cd762692 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -2440,7 +2440,7 @@ ex_listdo(eap) win_T *wp; tabpage_T *tp; #endif - buf_T *buf; + buf_T *buf = curbuf; int next_fnum = 0; #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) char_u *save_ei = NULL; @@ -2493,20 +2493,28 @@ ex_listdo(eap) case CMD_argdo: i = eap->line1 - 1; break; - case CMD_bufdo: - i = eap->line1; - break; default: break; } /* set pcmark now */ 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 setpcmark(); listcmd_busy = TRUE; /* avoids setting pcmark below */ - while (!got_int) + while (!got_int && buf != NULL) { if (eap->cmdidx == CMD_argdo) { diff --git a/src/testdir/test_command_count.in b/src/testdir/test_command_count.in index a86931f43..bfde053a8 100644 --- a/src/testdir/test_command_count.in +++ b/src/testdir/test_command_count.in @@ -141,6 +141,7 @@ STARTTEST :let buffers = '' :.,$-bufdo let buffers .= ' '.bufnr('%') :call add(g:lines, 'bufdo:' . buffers) +:3bd :let buffers = '' :3,7bufdo let buffers .= ' '.bufnr('%') :call add(g:lines, 'bufdo:' . buffers) diff --git a/src/testdir/test_command_count.ok b/src/testdir/test_command_count.ok index 8fdbc7748..e74155ec1 100644 --- a/src/testdir/test_command_count.ok +++ b/src/testdir/test_command_count.ok @@ -34,5 +34,5 @@ aaa: 0 bbb: 0 ccc: 0 argdo: c d e windo: 2 3 4 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 diff --git a/src/version.c b/src/version.c index 41926a438..53b6cdb1e 100644 --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 646, +/**/ 645, /**/ 644, |