From 0e7bbccd71a2a9d0fb18fba32e8389cd19d51aef Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Tue, 19 Jun 2018 12:06:26 -0400 Subject: [PATCH] Fix stacking tabs setting with new_tab prev --- qutebrowser/mainwindow/tabbedbrowser.py | 17 +++++++------ tests/end2end/features/tabs.feature | 32 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index cc1be1c00..bc054900a 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -526,18 +526,21 @@ class TabbedBrowser(QWidget): else: pos = config.val.tabs.new_position.unrelated if pos == 'prev': - idx = self._tab_insert_idx_left - # On first sight, we'd think we have to decrement - # self._tab_insert_idx_left here, as we want the next tab to be - # *before* the one we just opened. However, since we opened a tab - # *before* the currently focused tab, indices will shift by - # 1 automatically. + if config.val.tabs.new_position.stacking: + idx = self._tab_insert_idx_left + # On first sight, we'd think we have to decrement + # self._tab_insert_idx_left here, as we want the next tab to be + # *before* the one we just opened. However, since we opened a tab + # *before* the currently focused tab, indices will shift by + # 1 automatically. + else: + idx = self.widget.currentIndex() elif pos == 'next': if config.val.tabs.new_position.stacking: idx = self._tab_insert_idx_right + self._tab_insert_idx_right += 1 else: idx = self.widget.currentIndex() + 1 - self._tab_insert_idx_right += 1 elif pos == 'first': idx = 0 elif pos == 'last': diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index 7cc63ce52..cb6fbd226 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -911,6 +911,22 @@ Feature: Tab management - data/navigate/prev.html - data/navigate/next.html + Scenario: stacking tabs opening tab with tabs.new_position.related prev + When I set tabs.new_position.related to prev + And I set tabs.new_position.stacking to true + And I set tabs.background to true + And I open about:blank + And I open data/navigate/index.html in a new tab + And I hint with args "all tab-bg" and follow a + And I hint with args "all tab-bg" and follow s + And I wait until data/navigate/prev.html is loaded + And I wait until data/navigate/next.html is loaded + Then the following tabs should be open: + - about:blank + - data/navigate/next.html + - data/navigate/prev.html + - data/navigate/index.html (active) + Scenario: no stacking tabs opening tab with tabs.new_position.related next When I set tabs.new_position.related to next And I set tabs.new_position.stacking to false @@ -927,6 +943,22 @@ Feature: Tab management - data/navigate/next.html - data/navigate/prev.html + Scenario: no stacking tabs opening tab with tabs.new_position.related prev + When I set tabs.new_position.related to prev + And I set tabs.new_position.stacking to false + And I set tabs.background to true + And I open about:blank + And I open data/navigate/index.html in a new tab + And I hint with args "all tab-bg" and follow a + And I hint with args "all tab-bg" and follow s + And I wait until data/navigate/prev.html is loaded + And I wait until data/navigate/next.html is loaded + Then the following tabs should be open: + - about:blank + - data/navigate/prev.html + - data/navigate/next.html + - data/navigate/index.html (active) + # :buffer Scenario: :buffer without args or count