vim-patch:9.1.1351: Return value of getcmdline() inconsistent in CmdlineLeavePre

Problem:  Return value of getcmdline() inconsistent in CmdlineLeavePre
          when leaving cmdline in different ways (after v9.1.1329).
Solution: Trigger CmdlineLeavePre before calling abandon_cmdline() so
          that getcmdline() can return the command line (zeertzjq).

closes: vim/vim#17218

9240369774
This commit is contained in:
zeertzjq
2025-04-29 07:13:51 +08:00
parent c64cada12e
commit afcc4e95d5
2 changed files with 27 additions and 10 deletions

View File

@@ -871,6 +871,11 @@ static uint8_t *command_line_enter(int firstc, int count, int indent, bool clear
state_enter(&s->state);
// Trigger CmdlineLeavePre autocommands if not already triggered.
if (!s->event_cmdlineleavepre_triggered) {
trigger_cmd_autocmd(s->cmdline_type, EVENT_CMDLINELEAVEPRE);
}
if (has_event(EVENT_CMDLINELEAVE)) {
save_v_event_T save_v_event;
dict_T *dict = get_v_event(&save_v_event);
@@ -950,11 +955,6 @@ static uint8_t *command_line_enter(int firstc, int count, int indent, bool clear
need_wait_return = false;
}
// Trigger CmdlineLeavePre autocommands if not already triggered.
if (!s->event_cmdlineleavepre_triggered) {
trigger_cmd_autocmd(s->cmdline_type, EVENT_CMDLINELEAVEPRE);
}
set_option_direct(kOptInccommand, CSTR_AS_OPTVAL(s->save_p_icm), 0, SID_NONE);
State = s->save_State;
if (cmdpreview != save_cmdpreview) {