diff --git a/src/keybindings.c b/src/keybindings.c index 971afb98..328278ad 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -632,7 +632,17 @@ static void on_document_close(GObject *obj, GeanyDocument *doc) { if (! main_status.quitting) { + GeanyDocument *last_doc; + + last_doc = g_queue_peek_head(mru_docs); + + if (DOC_VALID(last_doc) && document_get_current() == doc) + { + gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), + document_get_notebook_page(last_doc)); + } g_queue_remove(mru_docs, doc); + g_idle_add(on_idle_close, NULL); } } diff --git a/src/notebook.c b/src/notebook.c index 0f9e880b..465bee86 100644 --- a/src/notebook.c +++ b/src/notebook.c @@ -493,15 +493,6 @@ notebook_tab_close_clicked_cb(GtkButton *button, gpointer user_data) /* Always use this instead of gtk_notebook_remove_page(). */ void notebook_remove_page(gint page_num) { - gint curpage = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook)); - - /* Focus the next page, not the previous */ - if (curpage == page_num && file_prefs.tab_order_ltr) - { - gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), curpage + 1); - } - - /* now remove the page (so we don't temporarily switch to the previous page) */ gtk_notebook_remove_page(GTK_NOTEBOOK(main_widgets.notebook), page_num); tab_count_changed();