summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2015-01-07 16:54:21 +0100
committerBram Moolenaar <Bram@vim.org>2015-01-07 16:54:21 +0100
commita162bc555e74c1a4f1b7b49871e292e05141b054 (patch)
treef730d991cbbf9293059e4be0a931dd96b0429c45 /src
parent3ffc79a4a82918430940bfaa18f4da058fdbd0ca (diff)
downloadvim-a162bc555e74c1a4f1b7b49871e292e05141b054.zip
updated for version 7.4.566
Problem: :argdo, :bufdo, :windo and :tabdo don't take a range. Solution: Support the range. (Marcin Szamotulski)
Diffstat (limited to 'src')
-rw-r--r--src/ex_cmds.h16
-rw-r--r--src/ex_cmds2.c38
-rw-r--r--src/testdir/test_command_count.in34
-rw-r--r--src/testdir/test_command_count.ok5
-rw-r--r--src/version.c2
5 files changed, 83 insertions, 12 deletions
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
index 6396d60c2..50e82521a 100644
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -133,8 +133,8 @@ EX(CMD_argdelete, "argdelete", ex_argdelete,
BANG|RANGE|NOTADR|FILES|TRLBAR,
ADDR_ARGUMENTS),
EX(CMD_argdo, "argdo", ex_listdo,
- BANG|NEEDARG|EXTRA|NOTRLCOM,
- ADDR_LINES),
+ BANG|NEEDARG|EXTRA|NOTRLCOM|RANGE|NOTADR|DFLALL,
+ ADDR_ARGUMENTS),
EX(CMD_argedit, "argedit", ex_argedit,
BANG|NEEDARG|RANGE|NOTADR|FILE1|EDITCMD|ARGOPT|TRLBAR,
ADDR_ARGUMENTS),
@@ -220,8 +220,8 @@ EX(CMD_buffers, "buffers", buflist_list,
BANG|TRLBAR|CMDWIN,
ADDR_LINES),
EX(CMD_bufdo, "bufdo", ex_listdo,
- BANG|NEEDARG|EXTRA|NOTRLCOM,
- ADDR_LINES),
+ BANG|NEEDARG|EXTRA|NOTRLCOM|RANGE|NOTADR|DFLALL,
+ ADDR_BUFFERS),
EX(CMD_bunload, "bunload", ex_bunload,
BANG|RANGE|NOTADR|BUFNAME|COUNT|EXTRA|TRLBAR,
ADDR_LOADED_BUFFERS),
@@ -1384,8 +1384,8 @@ EX(CMD_tabclose, "tabclose", ex_tabclose,
RANGE|NOTADR|COUNT|BANG|TRLBAR|CMDWIN,
ADDR_TABS),
EX(CMD_tabdo, "tabdo", ex_listdo,
- NEEDARG|EXTRA|NOTRLCOM,
- ADDR_LINES),
+ NEEDARG|EXTRA|NOTRLCOM|RANGE|NOTADR|DFLALL,
+ ADDR_TABS),
EX(CMD_tabedit, "tabedit", ex_splitview,
BANG|FILE1|RANGE|NOTADR|ZEROR|EDITCMD|ARGOPT|TRLBAR,
ADDR_TABS),
@@ -1576,8 +1576,8 @@ EX(CMD_wincmd, "wincmd", ex_wincmd,
NEEDARG|WORD1|RANGE|NOTADR,
ADDR_WINDOWS),
EX(CMD_windo, "windo", ex_listdo,
- BANG|NEEDARG|EXTRA|NOTRLCOM,
- ADDR_LINES),
+ BANG|NEEDARG|EXTRA|NOTRLCOM|RANGE|NOTADR|DFLALL,
+ ADDR_WINDOWS),
EX(CMD_winpos, "winpos", ex_winpos,
EXTRA|TRLBAR|CMDWIN,
ADDR_LINES),
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 4614deab8..48badeb93 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -2472,15 +2472,36 @@ ex_listdo(eap)
| (eap->forceit ? CCGD_FORCEIT : 0)
| CCGD_EXCMD))
{
- /* start at the first argument/window/buffer */
i = 0;
+ /* start at the eap->line1 argument/window/buffer */
#ifdef FEAT_WINDOWS
wp = firstwin;
tp = first_tabpage;
#endif
+ switch (eap->cmdidx)
+ {
+#ifdef FEAT_WINDOWS
+ case CMD_windo:
+ for ( ; wp != NULL && i + 1 < eap->line1; wp = wp->w_next)
+ i++;
+ break;
+ case CMD_tabdo:
+ for( ; tp != NULL && i + 1 < eap->line1; tp = tp->tp_next)
+ i++;
+ break;
+#endif
+ 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, 0);
+ goto_buffer(eap, DOBUF_FIRST, FORWARD, i);
else
setpcmark();
listcmd_busy = TRUE; /* avoids setting pcmark below */
@@ -2506,7 +2527,6 @@ ex_listdo(eap)
}
if (curwin->w_arg_idx != i)
break;
- ++i;
}
#ifdef FEAT_WINDOWS
else if (eap->cmdidx == CMD_windo)
@@ -2541,6 +2561,8 @@ ex_listdo(eap)
}
}
+ ++i;
+
/* execute the command */
do_cmdline(eap->arg, eap->getline, eap->cookie,
DOCMD_VERBOSE + DOCMD_NOWAIT);
@@ -2548,7 +2570,7 @@ ex_listdo(eap)
if (eap->cmdidx == CMD_bufdo)
{
/* Done? */
- if (next_fnum < 0)
+ if (next_fnum < 0 || next_fnum > eap->line2)
break;
/* Check if the buffer still exists. */
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
@@ -2579,6 +2601,14 @@ ex_listdo(eap)
do_check_scrollbind(TRUE);
#endif
}
+
+#ifdef FEAT_WINDOWS
+ if (eap->cmdidx == CMD_windo || eap->cmdidx == CMD_tabdo)
+ if (i+1 > eap->line2)
+ break;
+#endif
+ if (eap->cmdidx == CMD_argdo && i >= eap->line2)
+ break;
}
listcmd_busy = FALSE;
}
diff --git a/src/testdir/test_command_count.in b/src/testdir/test_command_count.in
index e7dadd2be..16daad0b2 100644
--- a/src/testdir/test_command_count.in
+++ b/src/testdir/test_command_count.in
@@ -90,6 +90,40 @@ STARTTEST
:only!
:e! test.out
:call append(0, g:lines)
+:unlet g:lines
+:w|bd
+:se hidden
+:b1
+ENDTEST
+
+STARTTEST
+:only!
+:let g:lines = []
+:%argd
+:arga a b c d e f
+:3argu
+:let args = ''
+:.,$-argdo let args .= ' '.expand('%')
+:call add(g:lines, 'argdo:' . args)
+:split|split|split|split
+:2wincmd w
+:let windows = ''
+:.,$-windo let windows .= ' '.winnr()
+:call add(g:lines, 'windo:'. windows)
+:b2
+:let buffers = ''
+:.,$-bufdo let buffers .= ' '.bufnr('%')
+:call add(g:lines, 'bufdo:' . buffers)
+:let buffers = ''
+:3,7bufdo let buffers .= ' '.bufnr('%')
+:call add(g:lines, 'bufdo:' . buffers)
+:tabe|tabe|tabe|tabe
+:normal! 2gt
+:let tabpages = ''
+:.,$-tabdo let tabpages .= ' '.tabpagenr()
+:call add(g:lines, 'tabdo:' . tabpages)
+:e! test.out
+:call append('$', g:lines)
:w|qa!
ENDTEST
diff --git a/src/testdir/test_command_count.ok b/src/testdir/test_command_count.ok
index 6e85f29d9..a936715b3 100644
--- a/src/testdir/test_command_count.ok
+++ b/src/testdir/test_command_count.ok
@@ -28,3 +28,8 @@ $tabe 2
$+tabe E16: Invalid range
0tabm x
+argdo: c d e
+windo: 2 3 4
+bufdo: 2 3 4 5 6 7 8 9 10 12
+bufdo: 3 4 5 6 7
+tabdo: 2 3 4
diff --git a/src/version.c b/src/version.c
index 835afbbf0..6339bcb72 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 */
/**/
+ 566,
+/**/
565,
/**/
564,