Keep pinned tabs in place rather than moving them.

This commit is contained in:
Jay Kamat 2017-05-12 13:09:22 -07:00
parent 3e3f4b4164
commit 2ae1bfc033
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5
4 changed files with 10 additions and 29 deletions

View File

@ -831,13 +831,14 @@ Duplicate the current tab.
[[tab-close]]
=== tab-close
Syntax: +:tab-close [*--prev*] [*--next*] [*--opposite*]+
Syntax: +:tab-close [*--prev*] [*--next*] [*--opposite*] [*--force*]+
Close the current/[count]th tab.
==== optional arguments
* +*-p*+, +*--prev*+: Force selecting the tab before the current tab.
* +*-n*+, +*--next*+: Force selecting the tab after the current tab.
* +*-f*+, +*--force*+: Avoid confirmation for pinned tabs.
* +*-o*+, +*--opposite*+: Force selecting the tab in the opposite direction of what's configured in 'tabs->select-on-remove'.

View File

@ -257,28 +257,22 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', scope='window',
name='tab-pin')
@cmdutils.argument('index')
@cmdutils.argument('count', count=True)
def tab_pin(self, index=None, count=None):
def tab_pin(self, count=None):
"""Pin/Unpin the current tab.
Args:
index: Location where the tab should be pinned/unpinned.
count: The tab index to pin or unpin, or None
"""
tabbar = self._tabbed_browser.tabBar()
tab = self._cntwidget(count)
if tab is None:
return
tab.data.pinned = not tab.data.pinned
if tab.data.pinned:
index = tabbar.pinned_count + 1 if index is None else int(index)
else:
index = self._count() if index is None else int(index)
self.tab_move(index)
self._tabbed_browser.set_tab_pinned(self._current_index(),
tab_index = self._current_index() if count is None else count - 1
cmdutils.check_overflow(tab_index + 1, 'int')
self._tabbed_browser.set_tab_pinned(tab_index,
tab.data.pinned)
@cmdutils.register(instance='command-dispatcher', name='open',

View File

@ -375,18 +375,15 @@ Feature: Saving and loading sessions
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-prev
And I run :tab-pin
And I run :tab-next
And I run :run-with-count 2 :tab-pin
And I run :session-save pin_session
And I run :tab-only
And I run :tab-close --force
And I run :session-load -c pin_session
And I run :tab-prev
And I run :open data/numbers/4.txt
And I wait 10s
Then the message "Tab is pinned!" should be shown
And the following tabs should be open:
- data/numbers/2.txt (active)
- data/numbers/1.txt
- data/numbers/2.txt (active)
- data/numbers/3.txt

View File

@ -1035,9 +1035,9 @@ Feature: Tab management
And I open data/numbers/3.txt in a new tab
And I run :tab-pin
Then the following tabs should be open:
- data/numbers/3.txt (active)
- data/numbers/1.txt
- data/numbers/2.txt
- data/numbers/3.txt (active)
Scenario: :tab-pin unpin
When I open data/numbers/1.txt
@ -1054,22 +1054,11 @@ Feature: Tab management
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 2
And I run :run-with-count 2 :tab-pin
Then the following tabs should be open:
- data/numbers/1.txt
- data/numbers/3.txt (active)
- data/numbers/2.txt
Scenario: :tab-pin unpin to index 1
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
And I run :tab-pin 1
Then the following tabs should be open:
- data/numbers/3.txt (active)
- data/numbers/1.txt
- data/numbers/2.txt
Scenario: Pinned :tab-close prompt yes
When I open data/numbers/1.txt