From 57adcea58740663a3bb01a155f19b72a4b0efe51 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 7 Dec 2016 07:01:06 +0100 Subject: [PATCH] Fix QTBUG-54419 workaround with tabs-are-windows set Fixes #2162 --- qutebrowser/mainwindow/tabbedbrowser.py | 11 ++++++++--- tests/end2end/features/tabs.feature | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index eb3b97e2c..6d46abbf8 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -346,7 +346,8 @@ class TabbedBrowser(tabwidget.TabWidget): @pyqtSlot('QUrl') @pyqtSlot('QUrl', bool) - def tabopen(self, url=None, background=None, explicit=False, idx=None): + def tabopen(self, url=None, background=None, explicit=False, idx=None, *, + ignore_tabs_are_windows=False): """Open a new tab with a given URL. Inner logic for open-tab and open-tab-bg. @@ -363,6 +364,8 @@ class TabbedBrowser(tabwidget.TabWidget): the current. - Explicitly opened tabs are at the very right. idx: The index where the new tab should be opened. + ignore_tabs_are_windows: If given, never open a new window, even + with tabs-are-windows set. Return: The opened WebView instance. @@ -373,7 +376,8 @@ class TabbedBrowser(tabwidget.TabWidget): "explicit {}, idx {}".format( url, background, explicit, idx)) - if config.get('tabs', 'tabs-are-windows') and self.count() > 0: + if (config.get('tabs', 'tabs-are-windows') and self.count() > 0 and + not ignore_tabs_are_windows): from qutebrowser.mainwindow import mainwindow window = mainwindow.MainWindow() window.show() @@ -528,7 +532,8 @@ class TabbedBrowser(tabwidget.TabWidget): background = self.currentIndex() != idx self.setUpdatesEnabled(False) try: - self.tabopen(url, background=background, idx=idx) + self.tabopen(url, background=background, idx=idx, + ignore_tabs_are_windows=True) self.close_tab(tab, add_undo=False) finally: self.setUpdatesEnabled(True) diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index 8066a6518..9d32fc126 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -973,6 +973,8 @@ Feature: Tab management And I run :buffer "1/2/3" Then the error "No matching tab for: 1/2/3" should be shown + # Other + Scenario: Using :tab-next after closing last tab (#1448) When I set tabs -> last-close to close And I run :tab-only @@ -986,3 +988,18 @@ Feature: Tab management And I run :tab-close ;; tab-prev Then qutebrowser should quit And no crash should happen + + Scenario: Opening link with tabs-are-windows set (#2162) + When I set tabs -> tabs-are-windows to true + And I open data/hints/html/simple.html + And I hint with args "all tab-fg" and follow a + And I wait until data/hello.txt is loaded + Then the session should look like: + windows: + - tabs: + - history: + - url: about:blank + - url: http://localhost:*/data/hints/html/simple.html + - tabs: + - history: + - url: http://localhost:*/data/hello.txt