From 3317834b3626c41cbe803c4c22c5b4485e8b92ce Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Thu, 11 May 2017 13:28:26 -0700 Subject: [PATCH] Fix a bug where pinned tabs were occasionally miscounted Example case: :tab-only. This should cover other cases, but currently those cases (such as :tab-only) do NOT have a warning message when popping up. --- qutebrowser/browser/commands.py | 12 +++++------- qutebrowser/mainwindow/tabbedbrowser.py | 4 ++++ tests/end2end/features/conftest.py | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index f55e77c6f..2bc91c8b3 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -220,9 +220,6 @@ class CommandDispatcher: self._tabbed_browser.close_tab(tab) tabbar.setSelectionBehaviorOnRemove(old_selection_behavior) - if tab.data.pinned: - tabbar.pinned_count -= 1 - @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('count', count=True) def tab_close(self, prev=False, next_=False, opposite=False, @@ -241,12 +238,13 @@ class CommandDispatcher: if tab is None: return close = functools.partial(self._tab_close, tab, prev, - next_, opposite) + next_, opposite) if tab.data.pinned and not force: - message.confirm_async(title='Pinned Tab', - text="Are you sure you want to close a pinned tab?", - yes_action=close, default=False) + message.confirm_async( + title='Pinned Tab', + text="Are you sure you want to close a pinned tab?", + yes_action=close, default=False) else: close() diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index 6bce2166a..41a7d00df 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -241,6 +241,10 @@ class TabbedBrowser(tabwidget.TabWidget): if last_close == 'ignore' and count == 1: return + # If we are removing a pinned tab, decrease count + if tab.data.pinned: + self.tabBar().pinned_count -= 1 + self._remove_tab(tab, add_undo=add_undo) if count == 1: # We just closed the last tab above. diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py index 2aa897dfa..3b6d86c3d 100644 --- a/tests/end2end/features/conftest.py +++ b/tests/end2end/features/conftest.py @@ -163,6 +163,7 @@ def clean_open_tabs(quteproc): quteproc.send_cmd(':tab-close --force') quteproc.wait_for_load_finished_url('about:blank') + @bdd.given('pdfjs is available') def pdfjs_available(): if not pdfjs.is_available():