Last active
January 2, 2019 14:01
-
-
Save ivan/844fa63ed8c99a34ca745406a0aca3db to your computer and use it in GitHub Desktop.
Chromium: always insert new tabs to the right of the current tab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/chrome/browser/ui/browser_commands.cc | |
+++ b/chrome/browser/ui/browser_commands.cc | |
@@ -627,12 +627,12 @@ void NewTab(Browser* browser) { | |
#endif | |
if (browser->is_type_tabbed()) { | |
- AddTabAt(browser, GURL(), -1, true); | |
+ AddTabAt(browser, GURL(), browser->tab_strip_model()->active_index() + 1, true); | |
browser->tab_strip_model()->GetActiveWebContents()->RestoreFocus(); | |
} else { | |
ScopedTabbedBrowserDisplayer displayer(browser->profile()); | |
Browser* b = displayer.browser(); | |
- AddTabAt(b, GURL(), -1, true); | |
+ AddTabAt(b, GURL(), browser->tab_strip_model()->active_index() + 1, true); | |
b->window()->Show(); | |
// The call to AddBlankTabAt above did not set the focus to the tab as its | |
// window was not active, so we have to do it explicitly. | |
--- a/chrome/browser/ui/tabs/tab_strip_model_order_controller.cc | |
+++ b/chrome/browser/ui/tabs/tab_strip_model_order_controller.cc | |
@@ -27,27 +27,8 @@ int TabStripModelOrderController::DetermineInsertionIndex( | |
if (!tab_count) | |
return 0; | |
- // NOTE: TabStripModel enforces that all non-mini-tabs occur after mini-tabs, | |
- // so we don't have to check here too. | |
- if (ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_LINK) && | |
- tabstrip_->active_index() != -1) { | |
- if (foreground) { | |
- // If the page was opened in the foreground by a link click in another | |
- // tab, insert it adjacent to the tab that opened that link. | |
- return tabstrip_->active_index() + 1; | |
- } | |
- content::WebContents* opener = tabstrip_->GetActiveWebContents(); | |
- // Get the index of the next item opened by this tab, and insert after | |
- // it... | |
- int index = tabstrip_->GetIndexOfLastWebContentsOpenedBy( | |
- opener, tabstrip_->active_index()); | |
- if (index != TabStripModel::kNoTab) | |
- return index + 1; | |
- // Otherwise insert adjacent to opener... | |
- return tabstrip_->active_index() + 1; | |
- } | |
- // In other cases, such as Ctrl+T, open at the end of the strip. | |
- return tabstrip_->count(); | |
+ // Always insert to the right of the current tab | |
+ return tabstrip_->active_index() + 1; | |
} | |
int TabStripModelOrderController::DetermineNewSelectedIndex( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment