diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 49e037538..e17f6afac 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1348,12 +1348,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 relative 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 2b74df72b..cc1be1c00 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -533,7 +533,10 @@ class TabbedBrowser(QWidget): # *before* the currently focused tab, indices will shift by # 1 automatically. 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 5f5ae5d29..7cc63ce52 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -894,6 +894,39 @@ 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: 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 + # :buffer Scenario: :buffer without args or count