GNOME Bugzilla – Bug 731784
Closing a tab while focused on another jumps to a different tab
Last modified: 2015-06-10 12:13:13 UTC
If I am focused on a tab (with another two documents opened in tabs to the left and right of my current tab), closing the left tab moves focus to the right tab, instead of keeping focus on the current document.
I confirm, thanks for the bug report.
It seems to be a bug in GTK+, gedit simply calls gtk_container_remove() on the GtkNotebook.
Mhh, no it's probably not in GTK+. GTK+ master (3.13) with gedit master (3.13): KO GTK+ master (3.13) with gedit 3.10: OK So the bug has probably been introduced between gedit 3.10 and 3.12.
With git bisect, the result is: 70735305e3640fe07dcb1d5eb32e9883de34ea97 is the first bad commit commit 70735305e3640fe07dcb1d5eb32e9883de34ea97 Author: Ignacio Casal Quinteiro <icq@gnome.org> Date: Sun Jan 5 17:16:00 2014 +0100 Remove UI Manager left overs Strange, maybe the documents menu did something to prevent the bug from occurring.
Created attachment 285389 [details] [review] Bug Fixed
Comment on attachment 285389 [details] [review] Bug Fixed Thanks for looking at this bug. For the commit message, the bug reference should be the bug URL as the last line of the commit message. The first line should be short, with a more detailed message after that. For more information, see the HACKING file. When a tab is closed: 1. if the closed tab is not the current tab displayed, stay at the current tab. 2. if the closed tab is the current tab displayed, switch to the last focused page. When testing your patch, I still see the bug. Open gedit, open two new tabs so there are three unsaved documents, and the current tab is the third one. Close the first document -> instead of staying at Document 3, we are now at Document 2.
> When a tab is closed: > 2. if the closed tab is the current tab displayed, switch to the last focused > page. This actually doesn't work when closing the last tab. > curr = gtk_notebook_get_current_page (notebook); > > if (page_num == curr) > { > smart_tab_switching_on_closure (nb, GEDIT_TAB (page)); > } The problem is that the page is already removed, so for the last tab curr == page_num - 1. Maybe this "smart" tab switching should be removed, it is buggy and I don't think it improves a lot the usability. When closing a tab, a valid behavior is to stay more or less at the same place in the notebook, i.e. at the previous or next tab. It is easier, since it's the default behavior of GtkNotebook. The last focused tab can be one edited one hour ago, at a completely different location in the notebook, so jumping at this tab can be strange. For what it's worth, Firefox doesn't jump to the last focused page. Paolo, any thoughts on this? There is no comment in the code explaining why it was done like that (it was maybe taken from the epiphany code).
(In reply to comment #7) > Paolo, any thoughts on this? There is no comment in the code explaining why it > was done like that (it was maybe taken from the epiphany code). I prefer to keep our current choice, I find it useful to be able to switch to a tab to check something and then close it and be back to where I was. It used to work properly, if it is broken we need to fix it
Created attachment 294572 [details] [review] Fixing tab focus
Review of attachment 294572 [details] [review]: The commit message should contain more information, to explain why it fixes the bug, and be sure there is no other regressions.
Created attachment 295506 [details] [review] Fix tab focus Retrieve currently focused tab index and compare with closed tab index. Depend on that call smart switching. Previously it was always returning -1 as current_page index that's why I think it was switching the pages.
Created attachment 295722 [details] [review] Fix tab focus
Fixed: https://git.gnome.org/browse/gedit/commit/?id=334acf29ca5f9dcbed259bf5239e43f1aba1f0e7 The bug fix will be available for the next stable version of gedit, 3.18.