From 00f001729b29ed8f7b0f8210a3bab4778a873331 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Sun, 21 May 2017 20:29:11 -0700 Subject: [PATCH] Fix undo with pinned tabs Add tests for undo with a pinned tab Add tests for clone with a pinned tab --- qutebrowser/mainwindow/tabbedbrowser.py | 9 ++++++--- qutebrowser/misc/sessions.py | 3 ++- tests/end2end/features/tabs.feature | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index 02f555993..e1b9642fd 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -34,7 +34,8 @@ from qutebrowser.utils import (log, usertypes, utils, qtutils, objreg, urlutils, message) -UndoEntry = collections.namedtuple('UndoEntry', ['url', 'history', 'index']) +UndoEntry = collections.namedtuple('UndoEntry', + ['url', 'history', 'index', 'pinned']) class TabDeletedError(Exception): @@ -294,7 +295,8 @@ class TabbedBrowser(tabwidget.TabWidget): except browsertab.WebTabError: pass # special URL else: - entry = UndoEntry(tab.url(), history_data, idx) + entry = UndoEntry(tab.url(), history_data, idx, + tab.data.pinned) self._undo_stack.append(entry) tab.shutdown() @@ -325,7 +327,7 @@ class TabbedBrowser(tabwidget.TabWidget): use_current_tab = (only_one_tab_open and no_history and last_close_url_used) - url, history_data, idx = self._undo_stack.pop() + url, history_data, idx, pinned = self._undo_stack.pop() if use_current_tab: self.openurl(url, newtab=False) @@ -334,6 +336,7 @@ class TabbedBrowser(tabwidget.TabWidget): newtab = self.tabopen(url, background=False, idx=idx) newtab.history.deserialize(history_data) + self.set_tab_pinned(idx, pinned) @pyqtSlot('QUrl', bool) def openurl(self, url, newtab): diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py index c33dc8045..cd8d84c54 100644 --- a/qutebrowser/misc/sessions.py +++ b/qutebrowser/misc/sessions.py @@ -396,7 +396,8 @@ class SessionManager(QObject): if tab.get('active', False): tab_to_focus = i if new_tab.data.pinned: - tabbed_browser.set_tab_pinned(i, new_tab.data.pinned, loading=True) + tabbed_browser.set_tab_pinned( + i, new_tab.data.pinned, loading=True) if tab_to_focus is not None: tabbed_browser.setCurrentIndex(tab_to_focus) if win.get('active', False): diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index bec952d48..00fe5c16a 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -1124,3 +1124,23 @@ Feature: Tab management Then the message "Tab is pinned!" should be shown And the following tabs should be open: - data/numbers/1.txt (active) (pinned) + + Scenario: Cloning a pinned tab + When I open data/numbers/1.txt + And I run :tab-pin + And I run :tab-clone + And I wait until data/numbers/1.txt is loaded + Then the following tabs should be open: + - data/numbers/1.txt (pinned) + - data/numbers/1.txt (pinned) (active) + + Scenario: Undo a pinned tab + When I open data/numbers/1.txt + And I open data/numbers/2.txt in a new tab + And I run :tab-pin + And I run :tab-close --force + And I run :undo + And I wait until data/numbers/2.txt is loaded + Then the following tabs should be open: + - data/numbers/1.txt + - data/numbers/2.txt (pinned) (active)