diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 298ae7efc..0b7b9f730 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1475,12 +1475,27 @@ tabs.mousewheel_switching: tabs.new_position.related: default: next type: NewTabPosition - desc: Position of new tabs opened from another tab. + desc: >- + Position of new tabs opened from another tab. + + See `tabs.new_position.stacking` for controlling stacking behavior. tabs.new_position.unrelated: default: last type: NewTabPosition - desc: "Position of new tabs which aren't opened from another tab." + desc: >- + Position of new tabs which are not opened from another tab. + + See `tabs.new_position.stacking` for controlling stacking behavior. + +tabs.new_position.stacking: + default: true + type: Bool + desc: >- + Stack related tabs on top of each other when opened consecutively. + + Only applies `next` and `prev` values of `tabs.new_position.related` and + `tabs.new_position.unrelated`. tabs.padding: default: diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index d6164fd49..1f3484663 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -527,14 +527,20 @@ 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': - idx = self._tab_insert_idx_right + if config.val.tabs.new_position.stacking: + idx = self._tab_insert_idx_right + else: + idx = self.widget.currentIndex() + 1 self._tab_insert_idx_right += 1 elif pos == 'first': idx = 0 diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index 3f1be405a..7f4d4635c 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -894,6 +894,71 @@ Feature: Tab management - about:blank - data/hello.txt (active) + # stacking tabs + Scenario: 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 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/index.html (active) + - 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 + 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/index.html (active) + - 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