mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 20:38:18 +00:00
fix(api): fix nvim_parse_cmd interfere with printing line in Ex mode (#19400)
This commit is contained in:
@@ -1444,10 +1444,13 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er
|
|||||||
eap->getline = NULL;
|
eap->getline = NULL;
|
||||||
eap->cookie = NULL;
|
eap->cookie = NULL;
|
||||||
|
|
||||||
|
const bool save_ex_pressedreturn = ex_pressedreturn;
|
||||||
// Parse command modifiers
|
// Parse command modifiers
|
||||||
if (parse_command_modifiers(eap, errormsg, &cmdinfo->cmdmod, false) == FAIL) {
|
if (parse_command_modifiers(eap, errormsg, &cmdinfo->cmdmod, false) == FAIL) {
|
||||||
|
ex_pressedreturn = save_ex_pressedreturn;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
ex_pressedreturn = save_ex_pressedreturn;
|
||||||
after_modifier = eap->cmd;
|
after_modifier = eap->cmd;
|
||||||
|
|
||||||
// Save location after command modifiers
|
// Save location after command modifiers
|
||||||
@@ -2407,7 +2410,8 @@ char *ex_errmsg(const char *const msg, const char *const arg)
|
|||||||
/// - Set ex_pressedreturn for an empty command line.
|
/// - Set ex_pressedreturn for an empty command line.
|
||||||
///
|
///
|
||||||
/// @param skip_only if false, undo_cmdmod() must be called later to free
|
/// @param skip_only if false, undo_cmdmod() must be called later to free
|
||||||
/// any cmod_filter_pat and cmod_filter_regmatch.regprog.
|
/// any cmod_filter_pat and cmod_filter_regmatch.regprog,
|
||||||
|
/// and ex_pressedreturn may be set.
|
||||||
/// @param[out] errormsg potential error message.
|
/// @param[out] errormsg potential error message.
|
||||||
///
|
///
|
||||||
/// Call apply_cmdmod() to get the side effects of the modifiers:
|
/// Call apply_cmdmod() to get the side effects of the modifiers:
|
||||||
@@ -2421,7 +2425,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, cmdmod_T *cmod, bool
|
|||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
memset(cmod, 0, sizeof(*cmod));
|
CLEAR_POINTER(cmod);
|
||||||
|
|
||||||
// Repeat until no more command modifiers are found.
|
// Repeat until no more command modifiers are found.
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@@ -3624,6 +3624,38 @@ describe('API', function()
|
|||||||
eq('Error while parsing command line: E464: Ambiguous use of user-defined command',
|
eq('Error while parsing command line: E464: Ambiguous use of user-defined command',
|
||||||
pcall_err(meths.parse_cmd, 'F', {}))
|
pcall_err(meths.parse_cmd, 'F', {}))
|
||||||
end)
|
end)
|
||||||
|
it('does not interfere with printing line in Ex mode #19400', function()
|
||||||
|
local screen = Screen.new(60, 7)
|
||||||
|
screen:set_default_attr_ids({
|
||||||
|
[0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
|
||||||
|
[1] = {bold = true, reverse = true}, -- MsgSeparator
|
||||||
|
})
|
||||||
|
screen:attach()
|
||||||
|
insert([[
|
||||||
|
foo
|
||||||
|
bar]])
|
||||||
|
feed('gQ1')
|
||||||
|
screen:expect([[
|
||||||
|
foo |
|
||||||
|
bar |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{1: }|
|
||||||
|
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||||
|
:1^ |
|
||||||
|
]])
|
||||||
|
eq('Error while parsing command line', pcall_err(meths.parse_cmd, '', {}))
|
||||||
|
feed('<CR>')
|
||||||
|
screen:expect([[
|
||||||
|
foo |
|
||||||
|
bar |
|
||||||
|
{1: }|
|
||||||
|
Entering Ex mode. Type "visual" to go to Normal mode. |
|
||||||
|
:1 |
|
||||||
|
foo |
|
||||||
|
:^ |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
describe('nvim_cmd', function()
|
describe('nvim_cmd', function()
|
||||||
it('works', function ()
|
it('works', function ()
|
||||||
|
Reference in New Issue
Block a user