patch 9.1.1349: CmdlineLeavePre may trigger twice
Problem: CmdlineLeavePre may trigger twice
(after v9.1.1329)
Solution: check that the key was typed, trigger it when it wasn't before
(Girish Palya)
There are two problems:
- CmdlineLeavePre may be triggered twice when a cabbr is present.
- CmdlineLeavePre fails to trigger when exiting the command-line via
<Backspace>.
Check if the Carriage Return (Enter) key was actually typed.
Trigger the event when the command-line is exited using Backspace and
other keys.
closes: #17214
Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
b9ffbf57f8
commit
46755e6b52
@ -1620,6 +1620,7 @@ getcmdline_int(
|
||||
int did_save_ccline = FALSE;
|
||||
int cmdline_type;
|
||||
int wild_type = 0;
|
||||
int event_cmdlineleavepre_triggered = FALSE;
|
||||
|
||||
// one recursion level deeper
|
||||
++depth;
|
||||
@ -1917,8 +1918,15 @@ getcmdline_int(
|
||||
}
|
||||
|
||||
// Trigger CmdlineLeavePre autocommand
|
||||
if (c == '\n' || c == '\r' || c == K_KENTER || c == ESC || c == Ctrl_C)
|
||||
if (KeyTyped && (c == '\n' || c == '\r' || c == K_KENTER || c == ESC
|
||||
#ifdef UNIX
|
||||
|| c == intr_char
|
||||
#endif
|
||||
|| c == Ctrl_C))
|
||||
{
|
||||
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVEPRE);
|
||||
event_cmdlineleavepre_triggered = TRUE;
|
||||
}
|
||||
|
||||
// The wildmenu is cleared if the pressed key is not used for
|
||||
// navigating the wild menu (i.e. the key is not 'wildchar' or
|
||||
@ -2608,6 +2616,10 @@ returncmd:
|
||||
if (some_key_typed)
|
||||
need_wait_return = FALSE;
|
||||
|
||||
// Trigger CmdlineLeavePre autocommands if not already triggered.
|
||||
if (!event_cmdlineleavepre_triggered)
|
||||
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVEPRE);
|
||||
|
||||
// Trigger CmdlineLeave autocommands.
|
||||
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user