Index: gedit/ChangeLog
===================================================================
RCS file: /cvs/gnome/gedit/gedit/ChangeLog,v
retrieving revision 1.660
diff -u -p -r1.660 ChangeLog
--- gedit/ChangeLog	2 Oct 2004 17:06:30 -0000	1.660
+++ gedit/ChangeLog	2 Oct 2004 17:27:29 -0000
@@ -1,5 +1,12 @@
 2004-10-02  Paolo Maggi  <paolo@gnome.org>
 
+	* gedit-mdi-child.c (gedit_mdi_child_tab_close_clicked): If a view is closed 
+	while another one is active, re-activate the previous active view (fixes
+	bug #149811: after closing a document jump to document which has been 
+	open before)
+
+2004-10-02  Paolo Maggi  <paolo@gnome.org>
+
 	* gedit-mdi.c (gedit_mdi_drag_data_received_handler): always opens the 
 	dropped files in the right target gedit window (fixes bug #150485: 
 	Dragging and dropping doesn't choose the right window)
Index: gedit/gedit-mdi-child.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-mdi-child.c,v
retrieving revision 1.29
diff -u -p -r1.29 gedit-mdi-child.c
--- gedit/gedit-mdi-child.c	14 Jul 2004 15:16:14 -0000	1.29
+++ gedit/gedit-mdi-child.c	2 Oct 2004 17:27:30 -0000
@@ -457,13 +457,25 @@ gedit_mdi_child_get_config_string (Bonob
 static void
 gedit_mdi_child_tab_close_clicked (GtkWidget *button, GtkWidget *view)
 {
+	GtkWidget *active_view;
+
 	gedit_debug (DEBUG_MDI, "");
 
 	g_return_if_fail (GEDIT_IS_VIEW (view));
 
-	bonobo_mdi_set_active_view (BONOBO_MDI (gedit_mdi), view);
+	active_view = gedit_get_active_view();
+
+	if (active_view != view)
+		bonobo_mdi_set_active_view (BONOBO_MDI (gedit_mdi), view);
+	else
+		active_view = NULL;
 	
 	gedit_file_close (view);
+
+	/* If a view is closed while another one is active, re-activate the previous
+	 * active view */
+	if (active_view != NULL)
+		bonobo_mdi_set_active_view (BONOBO_MDI (gedit_mdi), active_view);
 }
 
 static void
