diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2015-04-29 02:11:30 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-04-29 02:11:30 -0400 |
commit | 45b617afada9304cb265aad02645b22d76dfc2d5 (patch) | |
tree | 7f28a768d2c88e646f1bc4e1b9e5b1ea604cce21 /src/nvim/ex_cmds2.c | |
parent | 6a8862ded4d6f1693ac591ac8e47d1acbd044c49 (diff) | |
parent | b46746b93ef298688cba3d8fbbcdae13e069935c (diff) | |
download | rneovim-45b617afada9304cb265aad02645b22d76dfc2d5.tar.gz rneovim-45b617afada9304cb265aad02645b22d76dfc2d5.tar.bz2 rneovim-45b617afada9304cb265aad02645b22d76dfc2d5.zip |
Merge pull request #2041 from fmoralesc/command-ranges
Command ranges (was PR #1793)
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; } |