From 596dee69d61baeb5cdbed8d9d044597f2038d275 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Thu, 29 Jun 2017 20:04:02 -0700 Subject: [PATCH] Clean up pin_tab Also add a test case for :pin-tab with an invalid count --- qutebrowser/browser/commands.py | 9 +-------- tests/end2end/features/tabs.feature | 11 +++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 54ee0d53e..f21115db5 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -277,16 +277,9 @@ class CommandDispatcher: """ tab = self._cntwidget(count) if tab is None: - return + raise cmdexc.CommandError("Tab {} does not exist!".format(count)) to_pin = not tab.data.pinned - tab_index = self._current_index() if count is None else count - 1 - cmdutils.check_overflow(tab_index + 1, 'int') - tab = self._cntwidget(count) - - if tab is None: - raise cmdexc.CommandError("Unable to find tab '{}'.".format(count)) - self._tabbed_browser.set_tab_pinned(tab, to_pin) @cmdutils.register(instance='command-dispatcher', name='open', diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index 9980b448f..1d3f22b10 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -1073,6 +1073,17 @@ Feature: Tab management - data/numbers/2.txt (pinned) - data/numbers/3.txt (active) + Scenario: :tab-pin with an invalid count + When I open data/numbers/1.txt + And I open data/numbers/2.txt in a new tab + And I open data/numbers/3.txt in a new tab + And I run :tab-pin with count 23 + Then the error "Tab 23 does not exist!" should be shown + And the following tabs should be open: + - data/numbers/1.txt + - data/numbers/2.txt + - data/numbers/3.txt (active) + Scenario: Pinned :tab-close prompt yes When I open data/numbers/1.txt And I run :tab-pin