diff options
author | Felipe Morales <hel.sheep@gmail.com> | 2015-01-20 01:02:35 -0300 |
---|---|---|
committer | Felipe Morales <hel.sheep@gmail.com> | 2015-04-28 23:08:31 -0300 |
commit | ff70129d96f44dcb773e6ce56bc824a04ba5d9a9 (patch) | |
tree | 23061dc08378b6dc620803cb46f3f6c113360757 /src/nvim/ex_cmds2.c | |
parent | ca883df007d7644a0ff4986d564ee8524f88c86b (diff) | |
download | rneovim-ff70129d96f44dcb773e6ce56bc824a04ba5d9a9.tar.gz rneovim-ff70129d96f44dcb773e6ce56bc824a04ba5d9a9.tar.bz2 rneovim-ff70129d96f44dcb773e6ce56bc824a04ba5d9a9.zip |
vim-patch:7.4.566
Problem: :argdo, :bufdo, :windo and :tabdo don't take a range.
Solution: Support the range. (Marcin Szamotulski)
https://code.google.com/p/vim/source/detail?r=v7-4-566
Diffstat (limited to 'src/nvim/ex_cmds2.c')
-rw-r--r-- | src/nvim/ex_cmds2.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 98e6d87196..e453d68247 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -1844,13 +1844,33 @@ void ex_listdo(exarg_T *eap) || !check_changed(curbuf, CCGD_AW | (eap->forceit ? CCGD_FORCEIT : 0) | CCGD_EXCMD)) { - /* start at the first argument/window/buffer */ i = 0; + /* start at the eap->line1 argument/window/buffer */ wp = firstwin; tp = first_tabpage; + switch (eap->cmdidx) { + 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; + 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 */ @@ -1873,7 +1893,6 @@ void ex_listdo(exarg_T *eap) } if (curwin->w_arg_idx != i) break; - ++i; } else if (eap->cmdidx == CMD_windo) { /* go to window "wp" */ if (!win_valid(wp)) @@ -1899,13 +1918,14 @@ void ex_listdo(exarg_T *eap) } } + ++i; /* execute the command */ do_cmdline(eap->arg, eap->getline, eap->cookie, DOCMD_VERBOSE + DOCMD_NOWAIT); 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. */ @@ -1939,6 +1959,14 @@ void ex_listdo(exarg_T *eap) if (curwin->w_p_scb) do_check_scrollbind(TRUE); } + if (eap->cmdidx == CMD_windo || eap->cmdidx == CMD_tabdo) { + if (i + 1 > eap->line2) { + break; + } + } + if (eap->cmdidx == CMD_argdo && i >= eap->line2) { + break; + } } listcmd_busy = FALSE; } |