This is a pretty frequent work pattern of mine:

1. Editing file A
2. Searching for function and opening file B
3. Closing file B because I just wanted to look at the function definition
4. Without this patch I get to the file following the B's tab (which
is just a random file) but my brain expects that I get to A

I know it's possible to kind of simulate the behaviour I want with
the "next to current" placement option but I really don't see a single
advantage of having tabs closed in sequential order. This is also
why I didn't make this behaviour optional. But maybe I miss some
use case of tabs being closed sequentially - just tell me.

Signed-off-by: Jiří Techet <[email protected]>
---
 src/keybindings.c |   10 ++++++++++
 src/notebook.c    |    9 ---------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/keybindings.c b/src/keybindings.c
index 7c0beb4..b8e3f37 100644
--- a/src/keybindings.c
+++ b/src/keybindings.c
@@ -607,7 +607,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 a1d10bd..0a4af68 100644
--- a/src/notebook.c
+++ b/src/notebook.c
@@ -551,15 +551,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();
_______________________________________________
Geany-devel mailing list
[email protected]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel

Reply via email to