updated for version 7.0173
diff --git a/src/fileio.c b/src/fileio.c
index 0cfbc22..5b083f9 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -7483,6 +7483,8 @@
* :autocmd bufleave * set tw=79 nosmartindent ic infercase
*
* :autocmd * *.c show all autocommands for *.c files.
+ *
+ * Mostly a {group} argument can optionally appear before <event>.
*/
void
do_autocmd(arg, forceit)
@@ -8168,11 +8170,26 @@
}
#if defined(FEAT_AUTOCMD) || defined(PROTO)
+/*
+ * Return TRUE when there is a CursorHold autocommand defined.
+ */
int
has_cursorhold()
{
return (first_autopat[(int)EVENT_CURSORHOLD] != NULL);
}
+
+/*
+ * Return TRUE if the CursorHold event can be triggered.
+ */
+ int
+trigger_cursorhold()
+{
+ return (!did_cursorhold
+ && has_cursorhold()
+ && !Recording
+ && get_real_state() == NORMAL_BUSY);
+}
#endif
static int
diff --git a/src/gui.c b/src/gui.c
index 32416cb..75085ce 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -2653,8 +2653,7 @@
if (gui_mch_wait_for_chars(p_ut) == OK)
retval = OK;
#ifdef FEAT_AUTOCMD
- else if (!did_cursorhold && has_cursorhold()
- && get_real_state() == NORMAL_BUSY)
+ else if (trigger_cursorhold())
{
char_u buf[3];
@@ -4639,7 +4638,7 @@
u_sync();
del_bytes((long)(regmatch.endp[0] - regmatch.startp[0]),
- FALSE);
+ FALSE, FALSE);
ins_str(repl_text);
}
}
diff --git a/src/os_unix.c b/src/os_unix.c
index 6165e9f..73693b6 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -342,11 +342,8 @@
if (WaitForChar(p_ut) == 0)
{
#ifdef FEAT_AUTOCMD
- if (!did_cursorhold
- && has_cursorhold()
- && get_real_state() == NORMAL_BUSY
- && maxlen >= 3
- && !typebuf_changed(tb_change_cnt))
+ if (trigger_cursorhold() && maxlen >= 3
+ && !typebuf_changed(tb_change_cnt))
{
buf[0] = K_SPECIAL;
buf[1] = KS_EXTRA;
diff --git a/src/os_win32.c b/src/os_win32.c
index 91bc87e..08df912 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -1383,8 +1383,7 @@
if (!WaitForChar(p_ut))
{
#ifdef FEAT_AUTOCMD
- if (!did_cursorhold && has_cursorhold()
- && get_real_state() == NORMAL_BUSY && maxlen >= 3)
+ if (trigger_cursorhold() && maxlen >= 3)
{
buf[0] = K_SPECIAL;
buf[1] = KS_EXTRA;