diff options
author | Florian Walch <florian@fwalch.com> | 2015-06-29 16:35:37 +0300 |
---|---|---|
committer | Florian Walch <florian@fwalch.com> | 2015-07-06 15:09:32 +0300 |
commit | e949c2bd62f399a04ae23570203d61344bdd69e9 (patch) | |
tree | 44f14979121c7e41a2b5080803b55e783cc1322f /src | |
parent | 1b78ad1c4d1533fe3089b9744a5306616e562f3e (diff) | |
download | rneovim-e949c2bd62f399a04ae23570203d61344bdd69e9.tar.gz rneovim-e949c2bd62f399a04ae23570203d61344bdd69e9.tar.bz2 rneovim-e949c2bd62f399a04ae23570203d61344bdd69e9.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_cmds2.c | 24 | ||||
-rw-r--r-- | src/nvim/testdir/test_command_count.in | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_command_count.ok | 2 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
4 files changed, 20 insertions, 9 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index d9a8dc2d69..d610aa6d19 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -1862,20 +1862,30 @@ void ex_listdo(exarg_T *eap) case CMD_argdo: i = eap->line1 - 1; break; - case CMD_bufdo: - i = eap->line1; - break; default: break; } + buf_T *buf = curbuf; /* set pcmark now */ - if (eap->cmdidx == CMD_bufdo) - goto_buffer(eap, DOBUF_FIRST, FORWARD, i); - else + if (eap->cmdidx == CMD_bufdo) { + /* 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) { /* go to argument "i" */ if (i == ARGCOUNT) diff --git a/src/nvim/testdir/test_command_count.in b/src/nvim/testdir/test_command_count.in index dd3c108360..170c810923 100644 --- a/src/nvim/testdir/test_command_count.in +++ b/src/nvim/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/nvim/testdir/test_command_count.ok b/src/nvim/testdir/test_command_count.ok index 8fdbc7748d..e74155ec1b 100644 --- a/src/nvim/testdir/test_command_count.ok +++ b/src/nvim/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/nvim/version.c b/src/nvim/version.c index 7a7492bc46..757fdf385c 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -163,7 +163,7 @@ static int included_patches[] = { //649, //648 NA //647 NA - //646, + 646, //645, //644 NA //643, |