fix(cmdline): trigger CmdlineChanged after command preview (#35254)

This commit is contained in:
zeertzjq
2025-08-09 09:16:13 +08:00
committed by GitHub
parent b2828af5b5
commit 5977bdba05
2 changed files with 54 additions and 23 deletions

View File

@@ -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.