aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNimit Bhardwaj <nimitbhardwaj@gmail.com>2018-04-11 22:16:05 +0530
committerJustin M. Keyes <justinkz@gmail.com>2018-04-21 13:06:46 +0200
commit51af911a271eb95c0032d25bef5e9313b81648b9 (patch)
tree222a1bdfa44ed14d12ac4e18f7665d8ecd96b9a6
parentfe5f38d8bd54248e4ea327a7f6ca52646799f3a4 (diff)
downloadrneovim-51af911a271eb95c0032d25bef5e9313b81648b9.tar.gz
rneovim-51af911a271eb95c0032d25bef5e9313b81648b9.tar.bz2
rneovim-51af911a271eb95c0032d25bef5e9313b81648b9.zip
inccommand: do not execute trailing commands #8256
fix #7494
-rw-r--r--src/nvim/ex_docmd.c5
-rw-r--r--test/functional/ui/inccommand_spec.lua17
2 files changed, 22 insertions, 0 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 7cd6dbdeca..0a20008cd9 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -603,6 +603,11 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline,
cmd_getline, cmd_cookie);
recursive--;
+ // Ignore trailing '|'-separated commands in preview-mode ('inccommand').
+ if (State & CMDPREVIEW) {
+ next_cmdline = NULL;
+ }
+
if (cmd_cookie == (void *)&cmd_loop_cookie)
/* Use "current_line" from "cmd_loop_cookie", it may have been
* incremented when defining a function. */
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index 27e4066d9f..7dfe59b8b0 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -1354,6 +1354,23 @@ describe("inccommand=nosplit", function()
:echo 'foo'^ |
]])
end)
+
+ it("does not execute trailing bar-separated commands #7494", function()
+ feed(':%s/two/three/g|q!')
+ screen:expect([[
+ Inc substitution on |
+ {12:three} lines |
+ Inc substitution on |
+ {12:three} lines |
+ |
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ :%s/two/three/g|q!^ |
+ ]])
+ eq(eval('v:null'), eval('v:exiting'))
+ end)
end)
describe(":substitute, 'inccommand' with a failing expression", function()