updated for version 7.3.867
Problem: Matchparen does not update match when using auto-indenting.
(Marc Aldorasi)
Solution: Add the TextChanged and TextChangedI autocommand events.
diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim
index 03a428d..32f0a83 100644
--- a/runtime/plugin/matchparen.vim
+++ b/runtime/plugin/matchparen.vim
@@ -14,6 +14,9 @@
augroup matchparen
" Replace all matchparen autocommands
autocmd! CursorMoved,CursorMovedI,WinEnter * call s:Highlight_Matching_Pair()
+ if exists('##TextChanged')
+ autocmd! TextChanged,TextChangedI * call s:Highlight_Matching_Pair()
+ endif
augroup END
" Skip the rest if it was already done.
diff --git a/src/edit.c b/src/edit.c
index 88fd18a..5d60951 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -1593,6 +1593,21 @@
last_cursormoved = curwin->w_cursor;
}
#endif
+#ifdef FEAT_AUTOCMD
+ /* Trigger TextChangedI if b_changedtick differs. */
+ if (!ready && has_textchangedI()
+ && last_changedtick != curbuf->b_changedtick
+# ifdef FEAT_INS_EXPAND
+ && !pum_visible()
+# endif
+ )
+ {
+ if (last_changedtick_buf == curbuf)
+ apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, FALSE, curbuf);
+ last_changedtick_buf = curbuf;
+ last_changedtick = curbuf->b_changedtick;
+ }
+#endif
if (must_redraw)
update_screen(0);
else if (clear_cmdline || redraw_cmdline)
diff --git a/src/fileio.c b/src/fileio.c
index c177e63..b5a49b8 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -7713,6 +7713,8 @@
{"TabLeave", EVENT_TABLEAVE},
{"TermChanged", EVENT_TERMCHANGED},
{"TermResponse", EVENT_TERMRESPONSE},
+ {"TextChanged", EVENT_TEXTCHANGED},
+ {"TextChangedI", EVENT_TEXTCHANGEDI},
{"User", EVENT_USER},
{"VimEnter", EVENT_VIMENTER},
{"VimLeave", EVENT_VIMLEAVE},
@@ -9138,6 +9140,24 @@
}
/*
+ * Return TRUE when there is a TextChanged autocommand defined.
+ */
+ int
+has_textchanged()
+{
+ return (first_autopat[(int)EVENT_TEXTCHANGED] != NULL);
+}
+
+/*
+ * Return TRUE when there is a TextChangedI autocommand defined.
+ */
+ int
+has_textchangedI()
+{
+ return (first_autopat[(int)EVENT_TEXTCHANGEDI] != NULL);
+}
+
+/*
* Return TRUE when there is an InsertCharPre autocommand defined.
*/
int
diff --git a/src/globals.h b/src/globals.h
index 332fedc..ac0eb18 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -1057,11 +1057,13 @@
EXTERN int autocmd_bufnr INIT(= 0); /* fnum for <abuf> on cmdline */
EXTERN char_u *autocmd_match INIT(= NULL); /* name for <amatch> on cmdline */
EXTERN int did_cursorhold INIT(= FALSE); /* set when CursorHold t'gerd */
-EXTERN pos_T last_cursormoved /* for CursorMoved event */
+EXTERN pos_T last_cursormoved /* for CursorMoved event */
# ifdef DO_INIT
= INIT_POS_T(0, 0, 0)
# endif
;
+EXTERN int last_changedtick INIT(= 0); /* for TextChanged event */
+EXTERN buf_T *last_changedtick_buf INIT(= NULL);
#endif
#ifdef FEAT_WINDOWS
diff --git a/src/main.c b/src/main.c
index 6c4f8ec..cba8dce 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1168,6 +1168,19 @@
}
#endif
+#ifdef FEAT_AUTOCMD
+ /* Trigger TextChanged if b_changedtick differs. */
+ if (!finish_op && has_textchanged()
+ && last_changedtick != curbuf->b_changedtick)
+ {
+ if (last_changedtick_buf == curbuf)
+ apply_autocmds(EVENT_TEXTCHANGED, NULL, NULL,
+ FALSE, curbuf);
+ last_changedtick_buf = curbuf;
+ last_changedtick = curbuf->b_changedtick;
+ }
+#endif
+
#if defined(FEAT_DIFF) && defined(FEAT_SCROLLBIND)
/* Scroll-binding for diff mode may have been postponed until
* here. Avoids doing it for every change. */
diff --git a/src/proto/fileio.pro b/src/proto/fileio.pro
index 113b668..61eb712 100644
--- a/src/proto/fileio.pro
+++ b/src/proto/fileio.pro
@@ -44,6 +44,8 @@
int trigger_cursorhold __ARGS((void));
int has_cursormoved __ARGS((void));
int has_cursormovedI __ARGS((void));
+int has_textchanged __ARGS((void));
+int has_textchangedI __ARGS((void));
int has_insertcharpre __ARGS((void));
void block_autocmds __ARGS((void));
void unblock_autocmds __ARGS((void));
diff --git a/src/version.c b/src/version.c
index c3e8f37..70a0437 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 867,
+/**/
866,
/**/
865,
diff --git a/src/vim.h b/src/vim.h
index fc23a47..fa2e075 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -1300,6 +1300,8 @@
EVENT_TABENTER, /* after entering a tab page */
EVENT_SHELLCMDPOST, /* after ":!cmd" */
EVENT_SHELLFILTERPOST, /* after ":1,2!cmd", ":w !cmd", ":r !cmd". */
+ EVENT_TEXTCHANGED, /* text was modified */
+ EVENT_TEXTCHANGEDI, /* text was modified in Insert mode*/
NUM_EVENTS /* MUST be the last one */
};