Clean up pin_tab

Also add a test case for :pin-tab with an invalid count
This commit is contained in:
Jay Kamat 2017-06-29 20:04:02 -07:00
parent 302961a86a
commit 596dee69d6
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5
2 changed files with 12 additions and 8 deletions

View File

@ -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',

View File

@ -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