aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_getln.c
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-11-26 15:54:03 +0300
committerZyX <kp-pav@yandex.ru>2017-11-26 15:54:03 +0300
commitb9c78130587e42ca3b6417b47fb739a166da8eb7 (patch)
tree142cf7dd0a87dfb32a20838e7683dd1980e4b3e7 /src/nvim/ex_getln.c
parent05a3c12118a6dae0ac8f3603f9ee4d9fd9450cce (diff)
parent207b7ca4bc16d52641eaa5244eef25a0dba91dbc (diff)
downloadrneovim-b9c78130587e42ca3b6417b47fb739a166da8eb7.tar.gz
rneovim-b9c78130587e42ca3b6417b47fb739a166da8eb7.tar.bz2
rneovim-b9c78130587e42ca3b6417b47fb739a166da8eb7.zip
Merge branch 'master' into expression-parser
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r--src/nvim/ex_getln.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 53f6ca0d2b..19fd4b70c5 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -350,8 +350,57 @@ static uint8_t *command_line_enter(int firstc, long count, int indent)
got_int = false;
s->state.check = command_line_check;
s->state.execute = command_line_execute;
+
+ TryState tstate;
+ Error err = ERROR_INIT;
+ bool tl_ret = true;
+ dict_T *dict = get_vim_var_dict(VV_EVENT);
+ char firstcbuf[2];
+ firstcbuf[0] = firstc > 0 ? firstc : '-';
+ firstcbuf[1] = 0;
+
+ if (has_event(EVENT_CMDLINEENTER)) {
+ // set v:event to a dictionary with information about the commandline
+ tv_dict_add_str(dict, S_LEN("cmdtype"), firstcbuf);
+ tv_dict_add_nr(dict, S_LEN("cmdlevel"), ccline.level);
+ tv_dict_set_keys_readonly(dict);
+ try_enter(&tstate);
+
+ apply_autocmds(EVENT_CMDLINEENTER, (char_u *)firstcbuf, (char_u *)firstcbuf,
+ false, curbuf);
+ tv_dict_clear(dict);
+
+
+ tl_ret = try_leave(&tstate, &err);
+ if (!tl_ret && ERROR_SET(&err)) {
+ msg_putchar('\n');
+ msg_printf_attr(hl_attr(HLF_E)|MSG_HIST, (char *)e_autocmd_err, err.msg);
+ api_clear_error(&err);
+ redrawcmd();
+ }
+ tl_ret = true;
+ }
+
state_enter(&s->state);
+ if (has_event(EVENT_CMDLINELEAVE)) {
+ tv_dict_add_str(dict, S_LEN("cmdtype"), firstcbuf);
+ tv_dict_add_nr(dict, S_LEN("cmdlevel"), ccline.level);
+ tv_dict_set_keys_readonly(dict);
+ // not readonly:
+ tv_dict_add_special(dict, S_LEN("abort"),
+ s->gotesc ? kSpecialVarTrue : kSpecialVarFalse);
+ try_enter(&tstate);
+ apply_autocmds(EVENT_CMDLINELEAVE, (char_u *)firstcbuf, (char_u *)firstcbuf,
+ false, curbuf);
+ // error printed below, to avoid redraw issues
+ tl_ret = try_leave(&tstate, &err);
+ if (tv_dict_get_number(dict, "abort") != 0) {
+ s->gotesc = 1;
+ }
+ tv_dict_clear(dict);
+ }
+
cmdmsg_rl = false;
cmd_fkmap = 0;
@@ -412,8 +461,14 @@ static uint8_t *command_line_enter(int firstc, long count, int indent)
msg_scroll = s->save_msg_scroll;
redir_off = false;
+ if (!tl_ret && ERROR_SET(&err)) {
+ msg_putchar('\n');
+ msg_printf_attr(hl_attr(HLF_E)|MSG_HIST, (char *)e_autocmd_err, err.msg);
+ api_clear_error(&err);
+ }
+
// When the command line was typed, no need for a wait-return prompt.
- if (s->some_key_typed) {
+ if (s->some_key_typed && tl_ret) {
need_wait_return = false;
}