mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
'inccommand': Do not trigger during scripts, feedkeys().
This commit is contained in:
parent
527ba2b12a
commit
ff6ec703d5
@ -124,7 +124,7 @@ struct exarg {
|
|||||||
LineGetter getline; ///< Function used to get the next line
|
LineGetter getline; ///< Function used to get the next line
|
||||||
void *cookie; ///< argument for getline()
|
void *cookie; ///< argument for getline()
|
||||||
struct condstack *cstack; ///< condition stack for ":if" etc.
|
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"
|
#define FORCE_BIN 1 // ":edit ++bin file"
|
||||||
|
@ -1592,10 +1592,11 @@ static int command_line_changed(CommandLineState *s)
|
|||||||
redrawcmdline();
|
redrawcmdline();
|
||||||
s->did_incsearch = true;
|
s->did_incsearch = true;
|
||||||
} else if (s->firstc == ':'
|
} else if (s->firstc == ':'
|
||||||
|
&& KeyTyped // only if interactive
|
||||||
&& *p_icm != NUL // 'inccommand' is set
|
&& *p_icm != NUL // 'inccommand' is set
|
||||||
&& cmdline_star == 0 // not typing a password
|
&& cmdline_star == 0 // not typing a password
|
||||||
&& cmd_is_live(ccline.cmdbuff)) {
|
&& cmd_is_live(ccline.cmdbuff)) {
|
||||||
// process a "live" command
|
// process a "live" command ('inccommand')
|
||||||
do_cmdline(ccline.cmdbuff, NULL, NULL, DOCMD_KEEPLINE|DOCMD_LIVE);
|
do_cmdline(ccline.cmdbuff, NULL, NULL, DOCMD_KEEPLINE|DOCMD_LIVE);
|
||||||
redrawcmdline();
|
redrawcmdline();
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,8 @@ describe(":substitute, inccommand=split does not trigger preview", function()
|
|||||||
common_setup(nil, "split", default_text)
|
common_setup(nil, "split", default_text)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("when invoked by feedkeys() in a script ", function()
|
it("if invoked by a script ", function()
|
||||||
source(':call feedkeys(":%s/tw/MO/g\\<CR>")')
|
source('%s/tw/MO/g')
|
||||||
wait()
|
wait()
|
||||||
eq(1, eval("bufnr('$')"))
|
eq(1, eval("bufnr('$')"))
|
||||||
|
|
||||||
@ -67,8 +67,12 @@ describe(":substitute, inccommand=split does not trigger preview", function()
|
|||||||
expect(default_text:gsub("tw", "MO"))
|
expect(default_text:gsub("tw", "MO"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("when invoked directly in a script ", function()
|
it("if invoked by feedkeys()", function()
|
||||||
source('%s/tw/MO/g')
|
-- in a script...
|
||||||
|
source([[:call feedkeys(":%s/tw/MO/g\<CR>")]])
|
||||||
|
wait()
|
||||||
|
-- or interactively...
|
||||||
|
feed([[:call feedkeys(":%s/tw/MO/g\<CR>")<CR>]])
|
||||||
wait()
|
wait()
|
||||||
eq(1, eval("bufnr('$')"))
|
eq(1, eval("bufnr('$')"))
|
||||||
|
|
||||||
@ -1038,7 +1042,7 @@ describe("'inccommand' and :cnoremap", function()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('work with a failing mapping', function()
|
it('does not work with a failing mapping', function()
|
||||||
for _, case in pairs(cases) do
|
for _, case in pairs(cases) do
|
||||||
refresh(case)
|
refresh(case)
|
||||||
execute("cnoremap <expr> x execute('bwipeout!')[-1].'x'")
|
execute("cnoremap <expr> x execute('bwipeout!')[-1].'x'")
|
||||||
@ -1047,14 +1051,7 @@ describe("'inccommand' and :cnoremap", function()
|
|||||||
|
|
||||||
-- error thrown b/c of the mapping
|
-- error thrown b/c of the mapping
|
||||||
neq(nil, eval('v:errmsg'):find('^E523:'))
|
neq(nil, eval('v:errmsg'):find('^E523:'))
|
||||||
-- the substitution after the error only works for ics=split/nosplit
|
expect(default_text)
|
||||||
-- 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
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user