]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
updated for version 7.3.867 v7.3.867
authorBram Moolenaar <Bram@vim.org>
Tue, 19 Mar 2013 12:33:23 +0000 (13:33 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 19 Mar 2013 12:33:23 +0000 (13:33 +0100)
Problem:    Matchparen does not update match when using auto-indenting.
            (Marc Aldorasi)
Solution:   Add the TextChanged and TextChangedI autocommand events.

runtime/plugin/matchparen.vim
src/edit.c
src/fileio.c
src/globals.h
src/main.c
src/proto/fileio.pro
src/version.c
src/vim.h

index 03a428d6a83eb45aec2fb4baa99c5b8ffab16995..32f0a8349188c129664b822afddcff59f25d1d33 100644 (file)
@@ -14,6 +14,9 @@ let g:loaded_matchparen = 1
 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.
index 88fd18af1d1cbc2b4639e123d879f5e676f0e5c2..5d609519ac508b447cfa66c07791fddeceed4c61 100644 (file)
@@ -1592,6 +1592,21 @@ ins_redraw(ready)
 # endif
            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);
index c177e633c5a451795f023e744a7da6387cad7cdb..b5a49b87463af7df76725a59d3d40562c394ba46 100644 (file)
@@ -7713,6 +7713,8 @@ static struct event_name
     {"TabLeave",       EVENT_TABLEAVE},
     {"TermChanged",    EVENT_TERMCHANGED},
     {"TermResponse",   EVENT_TERMRESPONSE},
+    {"TextChanged",    EVENT_TEXTCHANGED},
+    {"TextChangedI",   EVENT_TEXTCHANGEDI},
     {"User",           EVENT_USER},
     {"VimEnter",       EVENT_VIMENTER},
     {"VimLeave",       EVENT_VIMLEAVE},
@@ -9137,6 +9139,24 @@ has_cursormovedI()
     return (first_autopat[(int)EVENT_CURSORMOVEDI] != NULL);
 }
 
+/*
+ * 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.
  */
index 332fedca99b5f4382974e2c657db5f59202e6243..ac0eb18e0646fbff4de24dc2d8d5b7e5ad3265a0 100644 (file)
@@ -1057,11 +1057,13 @@ EXTERN int      autocmd_fname_full;          /* autocmd_fname is full path */
 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
index 6c4f8eceeba2bbb3cfd5f767a8e92aa28e974c78..cba8dce75da05e63b06848624e36cac0279d2955 100644 (file)
@@ -1168,6 +1168,19 @@ main_loop(cmdwin, noexmode)
            }
 #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. */
index 113b668bdf7cc91bfca4fffb97e5fdb742f878b8..61eb712514bdb49b548e72a4854856bdcf0342cf 100644 (file)
@@ -44,6 +44,8 @@ int has_cursorhold __ARGS((void));
 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));
index c3e8f3773def49ea3af261edb27711f0318a81a0..70a04379e9f9aa3d5dc59830fd5573e6fa863321 100644 (file)
@@ -728,6 +728,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    867,
 /**/
     866,
 /**/
index fc23a4718a9aaaa7b9fecb2707f9e5215ef8756f..fa2e075b3aa71cad29e8568d3fa3cef144488201 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -1300,6 +1300,8 @@ enum auto_event
     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 */
 };