[gtksourceview/wip/regex-search] Search: fix bug in async forward/backward search
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/regex-search] Search: fix bug in async forward/backward search
- Date: Mon, 22 Jul 2013 12:05:55 +0000 (UTC)
commit 96b5116e7bf38f3fb84182c1006ec19d2e8c36b8
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Jul 22 14:04:30 2013 +0200
Search: fix bug in async forward/backward search
gtksourceview/gtksourcesearch.c | 38 ++++++++++++++++++++++++++++----------
1 files changed, 28 insertions(+), 10 deletions(-)
---
diff --git a/gtksourceview/gtksourcesearch.c b/gtksourceview/gtksourcesearch.c
index 1b7f47c..e621489 100644
--- a/gtksourceview/gtksourcesearch.c
+++ b/gtksourceview/gtksourcesearch.c
@@ -832,6 +832,7 @@ smart_forward_search_async_step (GtkSourceSearch *search,
{
GtkTextIter iter = *start_at;
GtkTextIter limit;
+ GtkTextIter region_start = *start_at;
GtkTextRegion *region = NULL;
ForwardBackwardData *task_data;
@@ -863,30 +864,38 @@ smart_forward_search_async_step (GtkSourceSearch *search,
{
gtk_text_iter_forward_to_tag_toggle (&iter, search->priv->found_tag);
}
+ else if (!gtk_text_iter_begins_tag (&iter, search->priv->found_tag))
+ {
+ gtk_text_iter_backward_to_tag_toggle (&iter, search->priv->found_tag);
+ region_start = iter;
+ }
limit = iter;
gtk_text_iter_forward_to_tag_toggle (&limit, search->priv->found_tag);
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, ®ion_start, &limit);
}
if (is_text_region_empty (region))
{
GtkTextIter match_start;
GtkTextIter match_end;
- gboolean found;
-
- found = basic_forward_search (search, &iter, &match_start, &match_end, &limit);
if (region != NULL)
{
gtk_text_region_destroy (region, TRUE);
}
- if (found)
+ while (basic_forward_search (search, &iter, &match_start, &match_end, &limit))
{
+ if (gtk_text_iter_compare (&match_start, start_at) < 0)
+ {
+ iter = match_end;
+ continue;
+ }
+
task_data = g_slice_new0 (ForwardBackwardData);
task_data->found = TRUE;
task_data->match_start = match_start;
@@ -961,6 +970,7 @@ smart_backward_search_async_step (GtkSourceSearch *search,
{
GtkTextIter iter = *start_at;
GtkTextIter limit;
+ GtkTextIter region_end = *start_at;
GtkTextRegion *region = NULL;
ForwardBackwardData *task_data;
@@ -994,30 +1004,38 @@ smart_backward_search_async_step (GtkSourceSearch *search,
{
gtk_text_iter_backward_to_tag_toggle (&iter, search->priv->found_tag);
}
+ else if (gtk_text_iter_has_tag (&iter, search->priv->found_tag))
+ {
+ gtk_text_iter_forward_to_tag_toggle (&iter, search->priv->found_tag);
+ region_end = iter;
+ }
limit = iter;
gtk_text_iter_backward_to_tag_toggle (&limit, search->priv->found_tag);
if (search->priv->scan_region != NULL)
{
- region = gtk_text_region_intersect (search->priv->scan_region, &limit, start_at);
+ region = gtk_text_region_intersect (search->priv->scan_region, &limit, ®ion_end);
}
if (is_text_region_empty (region))
{
GtkTextIter match_start;
GtkTextIter match_end;
- gboolean found;
-
- found = basic_backward_search (search, &iter, &match_start, &match_end, &limit);
if (region != NULL)
{
gtk_text_region_destroy (region, TRUE);
}
- if (found)
+ while (basic_backward_search (search, &iter, &match_start, &match_end, &limit))
{
+ if (gtk_text_iter_compare (start_at, &match_end) < 0)
+ {
+ iter = match_start;
+ continue;
+ }
+
task_data = g_slice_new0 (ForwardBackwardData);
task_data->found = TRUE;
task_data->match_start = match_start;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]