diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-11-22 18:05:36 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-11-22 18:05:36 +0100 |
commit | 568b1e253af78c7f19497daf1bbb442377bd1179 (patch) | |
tree | eef87cabdf4bb03927a482ac9e189e1749559172 | |
parent | cac9e3e049de88f5892719ac484d69aab3e688d5 (diff) | |
parent | 73aed03a7f9bb630ba6412abff22f52c56c00485 (diff) | |
download | qutebrowser-568b1e253af78c7f19497daf1bbb442377bd1179.tar.gz qutebrowser-568b1e253af78c7f19497daf1bbb442377bd1179.zip |
Merge remote-tracking branch 'origin/pr/6796'
-rw-r--r-- | qutebrowser/browser/commands.py | 5 | ||||
-rw-r--r-- | qutebrowser/mainwindow/tabbedbrowser.py | 5 | ||||
-rw-r--r-- | tests/end2end/features/tabs.feature | 37 |
3 files changed, 43 insertions, 4 deletions
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index edc7e6211..796bb2eb3 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -451,7 +451,7 @@ class CommandDispatcher: self._open(tab.url(), tab=True) if not keep: - tabbed_browser.close_tab(tab, add_undo=False) + tabbed_browser.close_tab(tab, add_undo=False, transfer=True) @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('win_id', completion=miscmodels.window) @@ -500,7 +500,8 @@ class CommandDispatcher: tabbed_browser.tabopen(self._current_url()) if not keep: self._tabbed_browser.close_tab(self._current_widget(), - add_undo=False) + add_undo=False, + transfer=True) def _back_forward(self, tab, bg, window, count, forward, index=None): """Helper function for :back/:forward.""" diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index e081284ee..8c6ac2424 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -406,15 +406,16 @@ class TabbedBrowser(QWidget): else: yes_action() - def close_tab(self, tab, *, add_undo=True, new_undo=True): + def close_tab(self, tab, *, add_undo=True, new_undo=True, transfer=False): """Close a tab. Args: tab: The QWebView to be closed. add_undo: Whether the tab close can be undone. new_undo: Whether the undo entry should be a new item in the stack. + transfer: Whether the tab is closing because it is moving to a new window. """ - if config.val.tabs.tabs_are_windows: + if config.val.tabs.tabs_are_windows or transfer: last_close = 'close' else: last_close = config.val.tabs.last_close diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index 469f4f00a..3715d5765 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -1370,6 +1370,25 @@ Feature: Tab management And I run :tab-take 0/1 Then the error "Can't take tabs when using windows as tabs" should be shown + @windows_skip + Scenario: Close the last tab of a window when taken by another window + Given I have a fresh instance + When I open data/numbers/1.txt + And I run :tab-only + And I open data/numbers/2.txt in a new window + And I set tabs.last_close to ignore + And I run :tab-take 1/1 + And I wait until data/numbers/2.txt is loaded + Then the session should look like: + windows: + - tabs: + - history: + - url: about:blank + - url: http://localhost:*/data/numbers/1.txt + - active: true + history: + - url: http://localhost:*/data/numbers/2.txt + # :tab-give @xfail_norun # Needs qutewm @@ -1427,6 +1446,24 @@ Feature: Tab management And I run :tab-give 0 Then the error "Can't give tabs when using windows as tabs" should be shown + @windows_skip + Scenario: Close the last tab of a window when given to another window + Given I have a fresh instance + When I open data/numbers/1.txt + And I run :tab-only + And I open data/numbers/2.txt in a new window + And I set tabs.last_close to ignore + And I run :tab-give 1 + And I wait until data/numbers/1.txt is loaded + Then the session should look like: + windows: + - tabs: + - active: true + history: + - url: http://localhost:*/data/numbers/2.txt + - history: + - url: http://localhost:*/data/numbers/1.txt + # Other Scenario: Using :tab-next after closing last tab (#1448) |