Skip to content

Commit

Permalink
When closing tab, return to the document at the top of the MRU list
Browse files Browse the repository at this point in the history
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 <techet@gmail.com>
  • Loading branch information
techee committed Dec 24, 2011
1 parent 0c6aed7 commit d0892b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 10 additions & 0 deletions src/keybindings.c
Expand Up @@ -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);
}
}
Expand Down
9 changes: 0 additions & 9 deletions src/notebook.c
Expand Up @@ -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();
Expand Down

0 comments on commit d0892b9

Please sign in to comment.