aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 7568d71ac0..45a11482d0 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1350,6 +1350,24 @@ static char_u * do_one_cmd(char_u **cmdlinep,
cmdmod.keepjumps = true;
continue;
+ case 'f': { // only accept ":filter {pat} cmd"
+ char_u *reg_pat;
+
+ if (!checkforcmd(&p, "filter", 4) || *p == NUL || ends_excmd(*p)) {
+ break;
+ }
+ p = skip_vimgrep_pat(p, &reg_pat, NULL);
+ if (p == NULL || *p == NUL) {
+ break;
+ }
+ cmdmod.filter_regmatch.regprog = vim_regcomp(reg_pat, RE_MAGIC);
+ if (cmdmod.filter_regmatch.regprog == NULL) {
+ break;
+ }
+ ea.cmd = p;
+ continue;
+ }
+
/* ":hide" and ":hide | cmd" are not modifiers */
case 'h': if (p != ea.cmd || !checkforcmd(&p, "hide", 3)
|| *p == NUL || ends_excmd(*p))
@@ -1452,6 +1470,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
}
break;
}
+ char_u *after_modifier = ea.cmd;
ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0
&& !(cstack->cs_flags[cstack->
@@ -1734,7 +1753,13 @@ static char_u * do_one_cmd(char_u **cmdlinep,
if (!ea.skip) {
STRCPY(IObuff, _("E492: Not an editor command"));
if (!(flags & DOCMD_VERBOSE)) {
- append_command(*cmdlinep);
+ // If the modifier was parsed OK the error must be in the following
+ // command
+ if (after_modifier != NULL) {
+ append_command(after_modifier);
+ } else {
+ append_command(*cmdlinep);
+ }
}
errormsg = IObuff;
did_emsg_syntax = TRUE;
@@ -2104,6 +2129,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
case CMD_echomsg:
case CMD_echon:
case CMD_execute:
+ case CMD_filter:
case CMD_help:
case CMD_hide:
case CMD_ijump:
@@ -2255,6 +2281,10 @@ doend:
free_string_option(cmdmod.save_ei);
}
+ if (cmdmod.filter_regmatch.regprog != NULL) {
+ vim_regfree(cmdmod.filter_regmatch.regprog);
+ }
+
cmdmod = save_cmdmod;
if (save_msg_silent != -1) {
@@ -2545,6 +2575,7 @@ static struct cmdmod {
{"botright", 2, FALSE},
{"browse", 3, FALSE},
{"confirm", 4, FALSE},
+ {"filter", 4, FALSE},
{"hide", 3, FALSE},
{"keepalt", 5, FALSE},
{"keepjumps", 5, FALSE},
@@ -3007,6 +3038,7 @@ const char * set_one_cmd_context(
case CMD_cfdo:
case CMD_confirm:
case CMD_debug:
+ case CMD_filter:
case CMD_folddoclosed:
case CMD_folddoopen:
case CMD_hide: