:tab-close option names
--left -> --prev --right -> --next
This commit is contained in:
parent
845298ae41
commit
7eafa30084
@ -841,13 +841,13 @@ How many tabs to switch forward.
|
|||||||
|
|
||||||
[[tab-only]]
|
[[tab-only]]
|
||||||
=== tab-only
|
=== tab-only
|
||||||
Syntax: +:tab-only [*--left*] [*--right*]+
|
Syntax: +:tab-only [*--prev*] [*--next*]+
|
||||||
|
|
||||||
Close all tabs except for the current one.
|
Close all tabs except for the current one.
|
||||||
|
|
||||||
==== optional arguments
|
==== optional arguments
|
||||||
* +*-l*+, +*--left*+: Keep tabs to the left of the current.
|
* +*-p*+, +*--prev*+: Keep tabs before the current.
|
||||||
* +*-r*+, +*--right*+: Keep tabs to the right of the current.
|
* +*-n*+, +*--next*+: Keep tabs after the current.
|
||||||
|
|
||||||
[[tab-prev]]
|
[[tab-prev]]
|
||||||
=== tab-prev
|
=== tab-prev
|
||||||
|
@ -801,20 +801,20 @@ class CommandDispatcher:
|
|||||||
message.info("Zoom level: {}%".format(level))
|
message.info("Zoom level: {}%".format(level))
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
@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.
|
"""Close all tabs except for the current one.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
left: Keep tabs to the left of the current.
|
prev: Keep tabs before the current.
|
||||||
right: Keep tabs to the right of 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()
|
cur_idx = self._tabbed_browser.currentIndex()
|
||||||
assert cur_idx != -1
|
assert cur_idx != -1
|
||||||
|
|
||||||
for i, tab in enumerate(self._tabbed_browser.widgets()):
|
for i, tab in enumerate(self._tabbed_browser.widgets()):
|
||||||
if (i == cur_idx or (left and i < cur_idx) or
|
if (i == cur_idx or (prev and i < cur_idx) or
|
||||||
(right and i > cur_idx)):
|
(next_ and i > cur_idx)):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
self._tabbed_browser.close_tab(tab)
|
self._tabbed_browser.close_tab(tab)
|
||||||
|
@ -1786,4 +1786,9 @@ CHANGED_KEY_COMMANDS = [
|
|||||||
(re.compile(r'^tab-close --left$'), r'tab-close --prev'),
|
(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 -r$'), r'tab-close --next'),
|
||||||
(re.compile(r'^tab-close --right$'), 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'),
|
||||||
]
|
]
|
||||||
|
@ -143,29 +143,29 @@ Feature: Tab management
|
|||||||
Then the following tabs should be open:
|
Then the following tabs should be open:
|
||||||
- data/numbers/3.txt (active)
|
- data/numbers/3.txt (active)
|
||||||
|
|
||||||
Scenario: :tab-only with --left
|
Scenario: :tab-only with --prev
|
||||||
When I open data/numbers/1.txt
|
When I open data/numbers/1.txt
|
||||||
And I open data/numbers/2.txt in a new tab
|
And I open data/numbers/2.txt in a new tab
|
||||||
And I open data/numbers/3.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-focus 2
|
||||||
And I run :tab-only --left
|
And I run :tab-only --prev
|
||||||
Then the following tabs should be open:
|
Then the following tabs should be open:
|
||||||
- data/numbers/1.txt
|
- data/numbers/1.txt
|
||||||
- data/numbers/2.txt (active)
|
- data/numbers/2.txt (active)
|
||||||
|
|
||||||
Scenario: :tab-only with --right
|
Scenario: :tab-only with --next
|
||||||
When I open data/numbers/1.txt
|
When I open data/numbers/1.txt
|
||||||
And I open data/numbers/2.txt in a new tab
|
And I open data/numbers/2.txt in a new tab
|
||||||
And I open data/numbers/3.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-focus 2
|
||||||
And I run :tab-only --right
|
And I run :tab-only --next
|
||||||
Then the following tabs should be open:
|
Then the following tabs should be open:
|
||||||
- data/numbers/2.txt (active)
|
- data/numbers/2.txt (active)
|
||||||
- data/numbers/3.txt
|
- data/numbers/3.txt
|
||||||
|
|
||||||
Scenario: :tab-only with --left and --right
|
Scenario: :tab-only with --prev and --next
|
||||||
When I run :tab-only --left --right
|
When I run :tab-only --prev --next
|
||||||
Then the error "Only one of -l/-r can be given!" should be shown
|
Then the error "Only one of -p/-n can be given!" should be shown
|
||||||
|
|
||||||
# :tab-focus
|
# :tab-focus
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user