diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-11-07 03:08:31 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-11-08 21:22:24 +0100 |
commit | ff6ec703d5f5b57a3c18034ba8a110ffcbf41cea (patch) | |
tree | 778fae537f22ec13628fbd42887673c97dcc4bb8 | |
parent | 527ba2b12ae71b3010df00f38bfb48a91a35a7d5 (diff) | |
download | rneovim-ff6ec703d5f5b57a3c18034ba8a110ffcbf41cea.tar.gz rneovim-ff6ec703d5f5b57a3c18034ba8a110ffcbf41cea.tar.bz2 rneovim-ff6ec703d5f5b57a3c18034ba8a110ffcbf41cea.zip |
'inccommand': Do not trigger during scripts, feedkeys().
-rw-r--r-- | src/nvim/ex_cmds_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 3 | ||||
-rw-r--r-- | test/functional/ui/inccommand_spec.lua | 23 |
3 files changed, 13 insertions, 15 deletions
diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 5b647ff69a..8a2ebe2cd4 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -124,7 +124,7 @@ struct exarg { LineGetter getline; ///< Function used to get the next line void *cookie; ///< argument for getline() struct condstack *cstack; ///< condition stack for ":if" etc. - bool is_live; ///< live preview + bool is_live; ///< 'inccommand' live preview }; #define FORCE_BIN 1 // ":edit ++bin file" diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 07b50a8056..04e7d2fbcf 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1592,10 +1592,11 @@ static int command_line_changed(CommandLineState *s) redrawcmdline(); s->did_incsearch = true; } else if (s->firstc == ':' + && KeyTyped // only if interactive && *p_icm != NUL // 'inccommand' is set && cmdline_star == 0 // not typing a password && cmd_is_live(ccline.cmdbuff)) { - // process a "live" command + // process a "live" command ('inccommand') do_cmdline(ccline.cmdbuff, NULL, NULL, DOCMD_KEEPLINE|DOCMD_LIVE); redrawcmdline(); } diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 03266ad163..09c47f1c34 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -58,8 +58,8 @@ describe(":substitute, inccommand=split does not trigger preview", function() common_setup(nil, "split", default_text) end) - it("when invoked by feedkeys() in a script ", function() - source(':call feedkeys(":%s/tw/MO/g\\<CR>")') + it("if invoked by a script ", function() + source('%s/tw/MO/g') wait() eq(1, eval("bufnr('$')")) @@ -67,8 +67,12 @@ describe(":substitute, inccommand=split does not trigger preview", function() expect(default_text:gsub("tw", "MO")) end) - it("when invoked directly in a script ", function() - source('%s/tw/MO/g') + it("if invoked by feedkeys()", function() + -- in a script... + source([[:call feedkeys(":%s/tw/MO/g\<CR>")]]) + wait() + -- or interactively... + feed([[:call feedkeys(":%s/tw/MO/g\<CR>")<CR>]]) wait() eq(1, eval("bufnr('$')")) @@ -1038,7 +1042,7 @@ describe("'inccommand' and :cnoremap", function() end end) - it('work with a failing mapping', function() + it('does not work with a failing mapping', function() for _, case in pairs(cases) do refresh(case) execute("cnoremap <expr> x execute('bwipeout!')[-1].'x'") @@ -1047,14 +1051,7 @@ describe("'inccommand' and :cnoremap", function() -- error thrown b/c of the mapping neq(nil, eval('v:errmsg'):find('^E523:')) - -- the substitution after the error only works for ics=split/nosplit - -- which seems like the right thing to do in all cases, but we probably - -- don't want to change the default, so all in all this seems alright - if case == '' then - expect(default_text) - else - expect(default_text:gsub("tw", "tox")) - end + expect(default_text) end end) |