]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.646 v7.4.646
authorBram Moolenaar <Bram@vim.org>
Fri, 27 Feb 2015 19:33:37 +0000 (20:33 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 27 Feb 2015 19:33:37 +0000 (20:33 +0100)
Problem:    ":bufdo" may start at a deleted buffer.
Solution:   Find the first not deleted buffer. (Shane Harper)

src/ex_cmds2.c
src/testdir/test_command_count.in
src/testdir/test_command_count.ok
src/version.c

index 48badeb93fbcfbf4f29acc46bff37881ef8da7be..2cd762692c99f48bc480a6db72f98411e4a9f9c5 100644 (file)
@@ -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)
            {
index a86931f4339d153eee0cd1badbde5ca05c5ed142..bfde053a8b079414478ed9c2800e11b735c23e9b 100644 (file)
@@ -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)
index 8fdbc7748ddd7a5d940ce4fb4198845a6b4b56fb..e74155ec1beae979d70e2539bbc4bb3dd0384f24 100644 (file)
@@ -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: 4 5 6 7
+bufdo: 4 5 6 7
 tabdo: 2 3 4
index 41926a43814aac073509833ce8b59ed9870d9119..53b6cdb1ea6dfdcb8de9e1a9de852c0fd28af5ab 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    646,
 /**/
     645,
 /**/