mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
fix(events): save v:event for cmdline autocommands separately
This commit is contained in:
@@ -738,13 +738,14 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init
|
|||||||
TryState tstate;
|
TryState tstate;
|
||||||
Error err = ERROR_INIT;
|
Error err = ERROR_INIT;
|
||||||
bool tl_ret = true;
|
bool tl_ret = true;
|
||||||
save_v_event_T save_v_event;
|
|
||||||
dict_T *dict = get_v_event(&save_v_event);
|
|
||||||
char firstcbuf[2];
|
char firstcbuf[2];
|
||||||
firstcbuf[0] = (char)(firstc > 0 ? firstc : '-');
|
firstcbuf[0] = (char)(firstc > 0 ? firstc : '-');
|
||||||
firstcbuf[1] = 0;
|
firstcbuf[1] = 0;
|
||||||
|
|
||||||
if (has_event(EVENT_CMDLINEENTER)) {
|
if (has_event(EVENT_CMDLINEENTER)) {
|
||||||
|
save_v_event_T save_v_event;
|
||||||
|
dict_T *dict = get_v_event(&save_v_event);
|
||||||
|
|
||||||
// set v:event to a dictionary with information about the commandline
|
// set v:event to a dictionary with information about the commandline
|
||||||
tv_dict_add_str(dict, S_LEN("cmdtype"), firstcbuf);
|
tv_dict_add_str(dict, S_LEN("cmdtype"), firstcbuf);
|
||||||
tv_dict_add_nr(dict, S_LEN("cmdlevel"), ccline.level);
|
tv_dict_add_nr(dict, S_LEN("cmdlevel"), ccline.level);
|
||||||
@@ -806,6 +807,9 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init
|
|||||||
state_enter(&s->state);
|
state_enter(&s->state);
|
||||||
|
|
||||||
if (has_event(EVENT_CMDLINELEAVE)) {
|
if (has_event(EVENT_CMDLINELEAVE)) {
|
||||||
|
save_v_event_T save_v_event;
|
||||||
|
dict_T *dict = get_v_event(&save_v_event);
|
||||||
|
|
||||||
tv_dict_add_str(dict, S_LEN("cmdtype"), firstcbuf);
|
tv_dict_add_str(dict, S_LEN("cmdtype"), firstcbuf);
|
||||||
tv_dict_add_nr(dict, S_LEN("cmdlevel"), ccline.level);
|
tv_dict_add_nr(dict, S_LEN("cmdlevel"), ccline.level);
|
||||||
tv_dict_set_keys_readonly(dict);
|
tv_dict_set_keys_readonly(dict);
|
||||||
|
@@ -185,6 +185,14 @@ describe('cmdline autocommands', function()
|
|||||||
eq({'notification', 'CmdlineLeave', {{cmdtype='=', cmdlevel=2, abort=false}}}, next_msg())
|
eq({'notification', 'CmdlineLeave', {{cmdtype='=', cmdlevel=2, abort=false}}}, next_msg())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('no crash with recursive use of v:event #19484', function()
|
||||||
|
command('autocmd CmdlineEnter * normal :')
|
||||||
|
feed(':')
|
||||||
|
eq({'notification', 'CmdlineEnter', {{cmdtype=':', cmdlevel=1}}}, next_msg())
|
||||||
|
feed('<CR>')
|
||||||
|
eq({'notification', 'CmdlineLeave', {{cmdtype=':', cmdlevel=1, abort=false}}}, next_msg())
|
||||||
|
end)
|
||||||
|
|
||||||
it('supports CmdlineChanged' ,function()
|
it('supports CmdlineChanged' ,function()
|
||||||
command("autocmd CmdlineChanged * call rpcnotify(g:channel, 'CmdlineChanged', v:event, getcmdline())")
|
command("autocmd CmdlineChanged * call rpcnotify(g:channel, 'CmdlineChanged', v:event, getcmdline())")
|
||||||
feed(':')
|
feed(':')
|
||||||
|
Reference in New Issue
Block a user