[anjuta] sourceview: Detect that a ifile_open() is a reload and save marks and position.



commit 287927abbad4b88b183ba9ece631947a1dd94b7e
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date:   Fri Jan 4 11:48:45 2013 +0100

    sourceview: Detect that a ifile_open() is a reload and save marks and position.
    
    So that when a document is reloaded from outside sourceview, marks
    and position is restored. Eg. when a reload is triggered from the
    DocumentManager menu item.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691121

 plugins/sourceview/sourceview.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/plugins/sourceview/sourceview.c b/plugins/sourceview/sourceview.c
index 2acf6ce..31ab768 100644
--- a/plugins/sourceview/sourceview.c
+++ b/plugins/sourceview/sourceview.c
@@ -546,11 +546,6 @@ on_reload_dialog_response (GtkWidget *message_area, gint res, Sourceview *sv)
 	{
 		GFile* file = sourceview_io_get_file (sv->priv->io);
 
-		/* Save marks and position */
-		sv->priv->goto_line =
-			LOCATION_TO_LINE(ianjuta_editor_get_lineno (IANJUTA_EDITOR(sv), NULL));
-		sourceview_reload_save_markers (sv);
-
 		ianjuta_file_open(IANJUTA_FILE(sv),
 						  file, NULL);
 		g_object_unref (file);
@@ -983,6 +978,18 @@ static void
 ifile_open (IAnjutaFile* ifile, GFile* file, GError** e)
 {
 	Sourceview* sv = ANJUTA_SOURCEVIEW(ifile);
+
+	GFile *previous_file;
+
+	previous_file = sourceview_io_get_file (sv->priv->io);
+	if (previous_file && g_file_equal (file, previous_file))
+	{
+		/* This is a reload so save marks and position */
+		sv->priv->goto_line =
+			LOCATION_TO_LINE(ianjuta_editor_get_lineno (IANJUTA_EDITOR(sv), NULL));
+		sourceview_reload_save_markers (sv);
+	}
+
 	/* Hold a reference here to avoid a destroyed editor */
 	g_object_ref(G_OBJECT(sv));
 	gtk_text_buffer_set_text (GTK_TEXT_BUFFER(sv->priv->document),



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