[gtk+] textiter: fix bug in find_visible_by_log_attrs()



commit dc1317a521f956cc1e42f442b43a87a48aa28337
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Tue Jul 15 19:02:54 2014 +0200

    textiter: fix bug in find_visible_by_log_attrs()
    
    find_by_log_attrs() can return true only in this case:
    return moved && !gtk_text_iter_is_end (arg_iter);
    
    So if the iter moved (i.e. something has been found), but is the end
    iter, find_by_log_attrs() returns false.
    
    Now the same checks are made in find_visible_by_log_attrs(). The public
    functions using find_visible_by_log_attrs() say in their documentation
    that false is returned for the end iter, hence the check with
    gtk_text_iter_is_end().
    
    https://bugzilla.gnome.org/show_bug.cgi?id=618852

 gtk/gtktextiter.c        |   11 +++++++++--
 testsuite/gtk/textiter.c |    4 ++--
 2 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c
index 889103e..5a53581 100644
--- a/gtk/gtktextiter.c
+++ b/gtk/gtktextiter.c
@@ -3183,12 +3183,19 @@ find_visible_by_log_attrs (GtkTextIter     *iter,
 
   pos = *iter;
 
-  while (find_by_log_attrs (&pos, func, forward))
+  while (TRUE)
     {
+      GtkTextIter pos_before = pos;
+
+      find_by_log_attrs (&pos, func, forward);
+
+      if (gtk_text_iter_equal (&pos_before, &pos))
+        break;
+
       if (!_gtk_text_btree_char_is_invisible (&pos))
        {
          *iter = pos;
-         return TRUE;
+         return !gtk_text_iter_is_end (iter);
        }
     }
 
diff --git a/testsuite/gtk/textiter.c b/testsuite/gtk/textiter.c
index f3b0963..ef8790d 100644
--- a/testsuite/gtk/textiter.c
+++ b/testsuite/gtk/textiter.c
@@ -475,7 +475,7 @@ test_visible_word_boundaries (void)
   check_backward_visible_word_start (buffer, 0, 0, FALSE);
 
   gtk_text_buffer_set_text (buffer, "ab", -1);
-  check_forward_visible_word_end (buffer, 0, 0, FALSE); /* FIXME result_offset should be 2 */
+  check_forward_visible_word_end (buffer, 0, 2, FALSE);
 
   /* Buffer contents: "b c " with "b" invisible */
   gtk_text_buffer_set_text (buffer, "", -1);
@@ -573,7 +573,7 @@ test_visible_cursor_positions (void)
   check_visible_cursor_position (buffer, TRUE, 0, 3, TRUE);
   check_visible_cursor_position (buffer, TRUE, 1, 3, TRUE);
   check_visible_cursor_position (buffer, TRUE, 2, 3, TRUE);
-  check_visible_cursor_position (buffer, TRUE, 3, 3, FALSE); /* FIXME result offset should be 4, not 3 */
+  check_visible_cursor_position (buffer, TRUE, 3, 4, FALSE);
   check_visible_cursor_position (buffer, TRUE, 4, 4, FALSE);
 
   /* backward */


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