From b23eabbd642a5d4c46a173d5324a76f4cb63c9f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Wilmet?= Date: Tue, 22 Sep 2015 14:40:57 +0200 Subject: textiter: fix bug in _gtk_text_btree_get_iter_at_last_toggle() If the last tag toggle is the end iter, the function returned the wrong tag toggle. This resulted in some bugs where the view wasn't relayout/redrawn correctly. The function also always returned TRUE, probably because the return value is used nowhere. But for consistency with _gtk_text_btree_get_iter_at_first_toggle(), it's better to keep the return value, and also because otherwise the function would be wrong (it doesn't always return a tag toggle, if there is none). https://bugzilla.gnome.org/show_bug.cgi?id=755413 --- gtk/gtktextiter.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c index c600b83258..6b31c6485c 100644 --- a/gtk/gtktextiter.c +++ b/gtk/gtktextiter.c @@ -5648,14 +5648,21 @@ _gtk_text_btree_get_iter_at_last_toggle (GtkTextBTree *tree, GtkTextIter *iter, GtkTextTag *tag) { + gboolean found; + g_return_val_if_fail (iter != NULL, FALSE); g_return_val_if_fail (tree != NULL, FALSE); _gtk_text_btree_get_end_iter (tree, iter); - gtk_text_iter_backward_to_tag_toggle (iter, tag); + + if (gtk_text_iter_toggles_tag (iter, tag)) + found = TRUE; + else + found = gtk_text_iter_backward_to_tag_toggle (iter, tag); + check_invariants (iter); - return TRUE; + return found; } gboolean -- cgit v1.2.1