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



commit bbbb5dc106f9bc97c677d39ba5ce8343ed733150
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 |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/gtksourceview/gtksourcesearchcontext.c b/gtksourceview/gtksourcesearchcontext.c
index 8535191..b07b5e8 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -1739,6 +1739,7 @@ regex_search_handle_high_priority_region (GtkSourceSearchContext *search)
        GtkSourceRegion *region;
        GtkSourceRegionIter region_iter;
 
+       /* FIXME intersect region */
        if (!gtk_source_region_get_bounds (search->priv->high_priority_region,
                                           &start,
                                           &end))
@@ -3983,13 +3984,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 +4015,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]