mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 22:18:33 +00:00
fix(inccommand): never preview if parsing command failed (#18944)
`errormsg` is not always set when parsing the command failed (e.g. when the range contains invalid marks). Check the return value is better.
This commit is contained in:
@@ -2393,11 +2393,12 @@ static void cmdpreview_show(CommandLineState *s)
|
||||
// Copy the command line so we can modify it.
|
||||
char *cmdline = xstrdup((char *)ccline.cmdbuff);
|
||||
char *errormsg = NULL;
|
||||
|
||||
parse_cmdline(cmdline, &ea, &cmdinfo, &errormsg);
|
||||
if (errormsg != NULL) {
|
||||
emsg_off++; // Block errors when parsing the command line, and don't update v:errmsg
|
||||
if (!parse_cmdline(cmdline, &ea, &cmdinfo, &errormsg)) {
|
||||
emsg_off--;
|
||||
goto end;
|
||||
}
|
||||
emsg_off--;
|
||||
|
||||
// Swap invalid command range if needed
|
||||
if ((ea.argt & EX_RANGE) && ea.line1 > ea.line2) {
|
||||
@@ -2421,7 +2422,8 @@ static void cmdpreview_show(CommandLineState *s)
|
||||
cmdmod_T save_cmdmod = cmdmod;
|
||||
|
||||
cmdpreview = true;
|
||||
emsg_silent++; // Block error reporting as the command may be incomplete
|
||||
emsg_silent++; // Block error reporting as the command may be incomplete,
|
||||
// but still update v:errmsg
|
||||
msg_silent++; // Block messages, namely ones that prompt
|
||||
block_autocmds(); // Block events
|
||||
garray_T save_view;
|
||||
|
Reference in New Issue
Block a user