[gedit-plugins/gnome-3-10] bookmarks: Fix on_delete_range



commit 9fee04f924130c7f21c151c697e8112273996996
Author: Volker Sobek <reklov live com>
Date:   Tue Nov 26 03:20:00 2013 +0100

    bookmarks: Fix on_delete_range
    
    When deleting a range that did not start at the beginning of a line,
    the bookmarks contained in the range were left in the buffer, in the
    middle of the line. This broke bookmark navigation. And in case the
    line didn't already have a bookmark at the beginning, it caused
    the bookmark pixbuf (star symbol) in the line marks to disappear.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=719345

 plugins/bookmarks/gedit-bookmarks-plugin.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/plugins/bookmarks/gedit-bookmarks-plugin.c b/plugins/bookmarks/gedit-bookmarks-plugin.c
index 452ead5..9c7ec8c 100644
--- a/plugins/bookmarks/gedit-bookmarks-plugin.c
+++ b/plugins/bookmarks/gedit-bookmarks-plugin.c
@@ -896,23 +896,29 @@ on_delete_range (GtkTextBuffer *buffer,
        GSList *marks;
        GSList *item;
 
+       /* After deleting, all bookmarks from the deleted range are collapsed at start. */
        iter = *start;
-
-       /* move to start of line */
-       gtk_text_iter_set_line_offset (&iter, 0);
-
-       /* remove any bookmarks that are collapsed on each other due to this */
-       marks = gtk_source_buffer_get_source_marks_at_iter (GTK_SOURCE_BUFFER (buffer),
-                                                           &iter,
+       marks = gtk_source_buffer_get_source_marks_at_line (GTK_SOURCE_BUFFER (buffer),
+                                                           gtk_text_iter_get_line (&iter),
                                                            BOOKMARK_CATEGORY);
 
        if (marks == NULL)
                return;
 
-       /* remove all but the first mark */
+       /* Remove all but the first bookmark. */
        for (item = marks->next; item; item = item->next)
                gtk_text_buffer_delete_mark (buffer, GTK_TEXT_MARK (item->data));
 
+       /* Make sure it is at the beginning of the line again. */
+       if (gtk_text_iter_get_line_offset (&iter) != 0)
+       {
+               gtk_text_iter_set_line_offset (&iter, 0);
+
+               gtk_text_buffer_move_mark (buffer,
+                                          GTK_TEXT_MARK (marks->data),
+                                          &iter);
+       }
+
        g_slist_free (marks);
 }
 


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