[gtksourceview/wip/search-start-signal] SearchContext: fix update_highlight() when called for several views



commit 8e5c9e0855e258fad5e1351bc3f3733cf56c94ea
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Aug 10 16:32:52 2016 +0200

    SearchContext: fix update_highlight() when called for several views

 gtksourceview/gtksourcesearchcontext.c |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/gtksourceview/gtksourcesearchcontext.c b/gtksourceview/gtksourcesearchcontext.c
index 8535191..021aefe 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -3983,13 +3983,14 @@ gtk_source_search_context_replace_all (GtkSourceSearchContext  *search,
        return nb_matches_replaced;
 }
 
+/* Highlight the [start,end] region in priority. */
 void
 _gtk_source_search_context_update_highlight (GtkSourceSearchContext *search,
                                             const GtkTextIter      *start,
                                             const GtkTextIter      *end,
                                             gboolean                synchronous)
 {
-       GtkSourceRegion *region_to_highlight;
+       GtkSourceRegion *region_to_highlight = NULL;
 
        g_return_if_fail (GTK_SOURCE_IS_SEARCH_CONTEXT (search));
        g_return_if_fail (start != NULL);
@@ -4013,16 +4014,19 @@ _gtk_source_search_context_update_highlight (GtkSourceSearchContext *search,
 
        if (!synchronous)
        {
-               /* The high priority region is used to highlight the region
-                * visible on screen. So if we are here, that means that the
-                * visible region has changed. So we can destroy the old
-                * high_priority_region.
-                */
-               g_clear_object (&search->priv->high_priority_region);
+               if (search->priv->high_priority_region == NULL)
+               {
+                       search->priv->high_priority_region = region_to_highlight;
+                       region_to_highlight = NULL;
+               }
+               else
+               {
+                       gtk_source_region_add_region (search->priv->high_priority_region,
+                                                     region_to_highlight);
+               }
 
-               search->priv->high_priority_region = region_to_highlight;
                install_idle_scan (search);
-               return;
+               goto out;
        }
 
        if (gtk_source_search_settings_get_regex_enabled (search->priv->settings))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]