diff src/screen.c @ 2284:cca510a8b85b vim73

Better init for match highlighting when using conceal feature.
author Bram Moolenaar <bram@vim.org>
date Mon, 05 Jul 2010 22:22:57 +0200
parents f42e0b5ff9e9
children 69064995302a
line wrap: on
line diff
--- a/src/screen.c
+++ b/src/screen.c
@@ -139,6 +139,7 @@ static void redraw_custom_statusline __A
 #define SEARCH_HL_PRIORITY 0
 static void start_search_hl __ARGS((void));
 static void end_search_hl __ARGS((void));
+static void init_search_hl __ARGS((win_T *wp));
 static void prepare_search_hl __ARGS((win_T *wp, linenr_T lnum));
 static void next_search_hl __ARGS((win_T *win, match_T *shl, linenr_T lnum, colnr_T mincol));
 #endif
@@ -609,7 +610,8 @@ update_single_line(wp, lnum)
 	    if (lnum == wp->w_lines[j].wl_lnum)
 	    {
 		screen_start();	/* not sure of screen cursor */
-# if defined(FEAT_SEARCH_EXTRA)
+# ifdef FEAT_SEARCH_EXTRA
+		init_search_hl(wp);
 		start_search_hl();
 		prepare_search_hl(wp, lnum);
 # endif
@@ -898,29 +900,7 @@ win_update(wp)
 #endif
 
 #ifdef FEAT_SEARCH_EXTRA
-    /* Setup for match and 'hlsearch' highlighting.  Disable any previous
-     * match */
-    cur = wp->w_match_head;
-    while (cur != NULL)
-    {
-	cur->hl.rm = cur->match;
-	if (cur->hlg_id == 0)
-	    cur->hl.attr = 0;
-	else
-	    cur->hl.attr = syn_id2attr(cur->hlg_id);
-	cur->hl.buf = buf;
-	cur->hl.lnum = 0;
-	cur->hl.first_lnum = 0;
-# ifdef FEAT_RELTIME
-	/* Set the time limit to 'redrawtime'. */
-	profile_setlimit(p_rdt, &(cur->hl.tm));
-# endif
-	cur = cur->next;
-    }
-    search_hl.buf = buf;
-    search_hl.lnum = 0;
-    search_hl.first_lnum = 0;
-    /* time limit is set at the toplevel, for all windows */
+    init_search_hl(wp);
 #endif
 
 #ifdef FEAT_LINEBREAK
@@ -6894,6 +6874,40 @@ end_search_hl()
 }
 
 /*
+ * Init for calling prepare_search_hl().
+ */
+    static void
+init_search_hl(wp)
+    win_T	*wp;
+{
+    matchitem_T *cur;
+
+    /* Setup for match and 'hlsearch' highlighting.  Disable any previous
+     * match */
+    cur = wp->w_match_head;
+    while (cur != NULL)
+    {
+	cur->hl.rm = cur->match;
+	if (cur->hlg_id == 0)
+	    cur->hl.attr = 0;
+	else
+	    cur->hl.attr = syn_id2attr(cur->hlg_id);
+	cur->hl.buf = wp->w_buffer;
+	cur->hl.lnum = 0;
+	cur->hl.first_lnum = 0;
+# ifdef FEAT_RELTIME
+	/* Set the time limit to 'redrawtime'. */
+	profile_setlimit(p_rdt, &(cur->hl.tm));
+# endif
+	cur = cur->next;
+    }
+    search_hl.buf = wp->w_buffer;
+    search_hl.lnum = 0;
+    search_hl.first_lnum = 0;
+    /* time limit is set at the toplevel, for all windows */
+}
+
+/*
  * Advance to the match in window "wp" line "lnum" or past it.
  */
     static void