mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
fix(cmdline): trigger CmdlineChanged after command preview (#35254)
This commit is contained in:
@@ -2793,15 +2793,6 @@ static void do_autocmd_cmdlinechanged(int firstc)
|
||||
|
||||
static int command_line_changed(CommandLineState *s)
|
||||
{
|
||||
if (ccline.cmdpos != s->prev_cmdpos
|
||||
|| (s->prev_cmdbuff != NULL
|
||||
&& strncmp(s->prev_cmdbuff, ccline.cmdbuff, (size_t)s->prev_cmdpos) != 0)) {
|
||||
// Trigger CmdlineChanged autocommands.
|
||||
do_autocmd_cmdlinechanged(s->firstc > 0 ? s->firstc : '-');
|
||||
}
|
||||
|
||||
may_trigger_cursormovedc(s);
|
||||
|
||||
const bool prev_cmdpreview = cmdpreview;
|
||||
if (s->firstc == ':'
|
||||
&& current_sctx.sc_sid == 0 // only if interactive
|
||||
@@ -2823,6 +2814,15 @@ static int command_line_changed(CommandLineState *s)
|
||||
}
|
||||
}
|
||||
|
||||
if (ccline.cmdpos != s->prev_cmdpos
|
||||
|| (s->prev_cmdbuff != NULL
|
||||
&& strncmp(s->prev_cmdbuff, ccline.cmdbuff, (size_t)s->prev_cmdpos) != 0)) {
|
||||
// Trigger CmdlineChanged autocommands.
|
||||
do_autocmd_cmdlinechanged(s->firstc > 0 ? s->firstc : '-');
|
||||
}
|
||||
|
||||
may_trigger_cursormovedc(s);
|
||||
|
||||
if (p_arshape && !p_tbidi) {
|
||||
// Always redraw the whole command line to fix shaping and
|
||||
// right-left typing. Not efficient, but it works.
|
||||
|
@@ -569,20 +569,51 @@ describe("'inccommand' for user commands", function()
|
||||
assert(screen._cursor.col < 12)
|
||||
end
|
||||
feed(':Test baz<Left><Left>arb')
|
||||
screen:expect({
|
||||
grid = [[
|
||||
Preview |
|
||||
oh no, even more text |
|
||||
will the text ever stop |
|
||||
oh well |
|
||||
did the text stop |
|
||||
why won't it stop |
|
||||
make the text stop |
|
||||
|
|
||||
{1:~ }|*8
|
||||
:Test barb^az |
|
||||
]],
|
||||
})
|
||||
screen:expect([[
|
||||
Preview |
|
||||
oh no, even more text |
|
||||
will the text ever stop |
|
||||
oh well |
|
||||
did the text stop |
|
||||
why won't it stop |
|
||||
make the text stop |
|
||||
|
|
||||
{1:~ }|*8
|
||||
:Test barb^az |
|
||||
]])
|
||||
end)
|
||||
|
||||
it('works when CmdlineChanged calls wildtrigger() #35246', function()
|
||||
api.nvim_buf_set_text(0, 0, 0, 1, -1, { '' })
|
||||
exec_lua([[
|
||||
vim.api.nvim_create_user_command("Repro", function() end, {
|
||||
nargs = '+',
|
||||
preview = function(opts, ns, buf)
|
||||
vim.api.nvim_buf_set_lines(0, 0, -1, true, { opts.args })
|
||||
return 2
|
||||
end
|
||||
})
|
||||
]])
|
||||
command([[autocmd CmdlineChanged [:/\?] call wildtrigger()]])
|
||||
command('set wildmode=noselect:lastused,full wildoptions=pum')
|
||||
feed(':Repro ')
|
||||
screen:expect([[
|
||||
|
|
||||
{1:~ }|*15
|
||||
:Repro ^ |
|
||||
]])
|
||||
feed('a')
|
||||
screen:expect([[
|
||||
a |
|
||||
{1:~ }|*15
|
||||
:Repro a^ |
|
||||
]])
|
||||
feed('bc')
|
||||
screen:expect([[
|
||||
abc |
|
||||
{1:~ }|*15
|
||||
:Repro abc^ |
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
||||
|
Reference in New Issue
Block a user