summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Kamat <jaygkamat@gmail.com>2017-06-29 20:04:02 -0700
committerJay Kamat <jaygkamat@gmail.com>2017-06-29 20:04:02 -0700
commit596dee69d61baeb5cdbed8d9d044597f2038d275 (patch)
tree7670ec9838195401508d90ee0915f1c043a3c643
parent302961a86aa0ba2a2998e8c21e0319f4f4a91f96 (diff)
downloadqutebrowser-596dee69d61baeb5cdbed8d9d044597f2038d275.tar.gz
qutebrowser-596dee69d61baeb5cdbed8d9d044597f2038d275.zip
Clean up pin_tab
Also add a test case for :pin-tab with an invalid count
-rw-r--r--qutebrowser/browser/commands.py9
-rw-r--r--tests/end2end/features/tabs.feature11
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