:tab-close option names

--left -> --prev
--right -> --next
This commit is contained in:
Daniel Karbach 2016-10-18 12:55:58 +02:00
parent 845298ae41
commit 7eafa30084
4 changed files with 21 additions and 16 deletions

View File

@ -841,13 +841,13 @@ How many tabs to switch forward.
[[tab-only]]
=== tab-only
Syntax: +:tab-only [*--left*] [*--right*]+
Syntax: +:tab-only [*--prev*] [*--next*]+
Close all tabs except for the current one.
==== optional arguments
* +*-l*+, +*--left*+: Keep tabs to the left of the current.
* +*-r*+, +*--right*+: Keep tabs to the right of the current.
* +*-p*+, +*--prev*+: Keep tabs before the current.
* +*-n*+, +*--next*+: Keep tabs after the current.
[[tab-prev]]
=== tab-prev

View File

@ -801,20 +801,20 @@ class CommandDispatcher:
message.info("Zoom level: {}%".format(level))
@cmdutils.register(instance='command-dispatcher', scope='window')
def tab_only(self, left=False, right=False):
def tab_only(self, prev=False, next_=False):
"""Close all tabs except for the current one.
Args:
left: Keep tabs to the left of the current.
right: Keep tabs to the right of the current.
prev: Keep tabs before the current.
next_: Keep tabs after the current.
"""
cmdutils.check_exclusive((left, right), 'lr')
cmdutils.check_exclusive((prev, next_), 'pn')
cur_idx = self._tabbed_browser.currentIndex()
assert cur_idx != -1
for i, tab in enumerate(self._tabbed_browser.widgets()):
if (i == cur_idx or (left and i < cur_idx) or
(right and i > cur_idx)):
if (i == cur_idx or (prev and i < cur_idx) or
(next_ and i > cur_idx)):
continue
else:
self._tabbed_browser.close_tab(tab)

View File

@ -1786,4 +1786,9 @@ CHANGED_KEY_COMMANDS = [
(re.compile(r'^tab-close --left$'), r'tab-close --prev'),
(re.compile(r'^tab-close -r$'), r'tab-close --next'),
(re.compile(r'^tab-close --right$'), r'tab-close --next'),
(re.compile(r'^tab-only -l$'), r'tab-only --prev'),
(re.compile(r'^tab-only --left$'), r'tab-only --prev'),
(re.compile(r'^tab-only -r$'), r'tab-only --next'),
(re.compile(r'^tab-only --right$'), r'tab-only --next'),
]

View File

@ -143,29 +143,29 @@ Feature: Tab management
Then the following tabs should be open:
- data/numbers/3.txt (active)
Scenario: :tab-only with --left
Scenario: :tab-only with --prev
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-focus 2
And I run :tab-only --left
And I run :tab-only --prev
Then the following tabs should be open:
- data/numbers/1.txt
- data/numbers/2.txt (active)
Scenario: :tab-only with --right
Scenario: :tab-only with --next
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-focus 2
And I run :tab-only --right
And I run :tab-only --next
Then the following tabs should be open:
- data/numbers/2.txt (active)
- data/numbers/3.txt
Scenario: :tab-only with --left and --right
When I run :tab-only --left --right
Then the error "Only one of -l/-r can be given!" should be shown
Scenario: :tab-only with --prev and --next
When I run :tab-only --prev --next
Then the error "Only one of -p/-n can be given!" should be shown
# :tab-focus