[gtksourceview/wip/search: 13/19] search: some fixes



commit 02de0501df24b4b3b8ff5be0d0c43606ef6d4a2c
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Jun 29 16:08:03 2013 +0200

    search: some fixes

 gtksourceview/gtksourcesearch.c |   40 ++++++++++++++------------------------
 1 files changed, 15 insertions(+), 25 deletions(-)
---
diff --git a/gtksourceview/gtksourcesearch.c b/gtksourceview/gtksourcesearch.c
index 74d49da..52ea71d 100644
--- a/gtksourceview/gtksourcesearch.c
+++ b/gtksourceview/gtksourcesearch.c
@@ -487,8 +487,7 @@ smart_forward_search_async (GtkSourceSearch   *search,
                init_found_tag (search);
        }
 
-       if (!gtk_text_iter_has_tag (&iter, search->priv->found_tag) ||
-           gtk_text_iter_ends_tag (&iter, search->priv->found_tag))
+       if (!gtk_text_iter_has_tag (&iter, search->priv->found_tag))
        {
                gtk_text_iter_forward_to_tag_toggle (&iter, search->priv->found_tag);
        }
@@ -582,8 +581,9 @@ smart_backward_search_async (GtkSourceSearch   *search,
                init_found_tag (search);
        }
 
-       if (!gtk_text_iter_has_tag (&iter, search->priv->found_tag) ||
-           gtk_text_iter_begins_tag (&iter, search->priv->found_tag))
+       if (gtk_text_iter_begins_tag (&iter, search->priv->found_tag) ||
+           (!gtk_text_iter_has_tag (&iter, search->priv->found_tag) &&
+            !gtk_text_iter_ends_tag (&iter, search->priv->found_tag)))
        {
                gtk_text_iter_backward_to_tag_toggle (&iter, search->priv->found_tag);
        }
@@ -593,7 +593,7 @@ smart_backward_search_async (GtkSourceSearch   *search,
 
        if (search->priv->scan_region != NULL)
        {
-               region = gtk_text_region_intersect (search->priv->scan_region, start_at, &limit);
+               region = gtk_text_region_intersect (search->priv->scan_region, &limit, start_at);
        }
 
        if (is_text_region_empty (region))
@@ -625,7 +625,7 @@ smart_backward_search_async (GtkSourceSearch   *search,
                        return;
                }
 
-               smart_forward_search_async (search, &limit, task);
+               smart_backward_search_async (search, &limit, task);
                return;
        }
 
@@ -687,11 +687,7 @@ adjust_subregion (GtkSourceSearch *search,
                if (is_text_region_empty (search->priv->scan_region))
                {
                        /* 'start' is in a correct match, we can skip it. */
-
-                       if (!gtk_text_iter_ends_tag (start, search->priv->found_tag))
-                       {
-                               gtk_text_iter_forward_to_tag_toggle (start, search->priv->found_tag);
-                       }
+                       gtk_text_iter_forward_to_tag_toggle (start, search->priv->found_tag);
                }
                else
                {
@@ -704,10 +700,7 @@ adjust_subregion (GtkSourceSearch *search,
                                gtk_text_iter_backward_to_tag_toggle (&tag_start, search->priv->found_tag);
                        }
 
-                       if (!gtk_text_iter_ends_tag (&tag_end, search->priv->found_tag))
-                       {
-                               gtk_text_iter_forward_to_tag_toggle (&tag_end, search->priv->found_tag);
-                       }
+                       gtk_text_iter_forward_to_tag_toggle (&tag_end, search->priv->found_tag);
 
                        region = gtk_text_region_intersect (search->priv->scan_region,
                                                            &tag_start,
@@ -760,10 +753,7 @@ adjust_subregion (GtkSourceSearch *search,
                                gtk_text_iter_backward_to_tag_toggle (&tag_start, search->priv->found_tag);
                        }
 
-                       if (!gtk_text_iter_ends_tag (&tag_end, search->priv->found_tag))
-                       {
-                               gtk_text_iter_forward_to_tag_toggle (&tag_end, search->priv->found_tag);
-                       }
+                       gtk_text_iter_forward_to_tag_toggle (&tag_end, search->priv->found_tag);
 
                        region = gtk_text_region_intersect (search->priv->scan_region,
                                                            &tag_start,
@@ -817,13 +807,13 @@ remove_occurrences_in_range (GtkSourceSearch *search,
        }
 
        if (gtk_text_iter_has_tag (start, search->priv->found_tag) &&
-           !gtk_text_iter_toggles_tag (start, search->priv->found_tag))
+           !gtk_text_iter_begins_tag (start, search->priv->found_tag))
        {
                gtk_text_iter_backward_to_tag_toggle (start, search->priv->found_tag);
        }
 
        if (gtk_text_iter_has_tag (end, search->priv->found_tag) &&
-           !gtk_text_iter_toggles_tag (end, search->priv->found_tag))
+           !gtk_text_iter_begins_tag (end, search->priv->found_tag))
        {
                gtk_text_iter_forward_to_tag_toggle (end, search->priv->found_tag);
        }
@@ -1156,8 +1146,7 @@ smart_forward_search (GtkSourceSearch   *search,
                init_found_tag (search);
        }
 
-       if (!gtk_text_iter_has_tag (&iter, search->priv->found_tag) ||
-           gtk_text_iter_ends_tag (&iter, search->priv->found_tag))
+       if (!gtk_text_iter_has_tag (&iter, search->priv->found_tag))
        {
                gtk_text_iter_forward_to_tag_toggle (&iter, search->priv->found_tag);
        }
@@ -1214,8 +1203,9 @@ smart_backward_search (GtkSourceSearch   *search,
                init_found_tag (search);
        }
 
-       if (!gtk_text_iter_has_tag (&iter, search->priv->found_tag) ||
-           gtk_text_iter_begins_tag (&iter, search->priv->found_tag))
+       if (gtk_text_iter_begins_tag (&iter, search->priv->found_tag) ||
+           (!gtk_text_iter_has_tag (&iter, search->priv->found_tag) &&
+            !gtk_text_iter_ends_tag (&iter, search->priv->found_tag)))
        {
                gtk_text_iter_backward_to_tag_toggle (&iter, search->priv->found_tag);
        }


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