:tab-close option names
--left -> --prev --right -> --next
This commit is contained in:
parent
828b7d744a
commit
845298ae41
@ -779,13 +779,13 @@ Duplicate the current tab.
|
||||
|
||||
[[tab-close]]
|
||||
=== tab-close
|
||||
Syntax: +:tab-close [*--left*] [*--right*] [*--opposite*]+
|
||||
Syntax: +:tab-close [*--prev*] [*--next*] [*--opposite*]+
|
||||
|
||||
Close the current/[count]th tab.
|
||||
|
||||
==== optional arguments
|
||||
* +*-l*+, +*--left*+: Force selecting the tab to the left of the current tab.
|
||||
* +*-r*+, +*--right*+: Force selecting the tab to the right of the current tab.
|
||||
* +*-p*+, +*--prev*+: Force selecting the tab before the current tab.
|
||||
* +*-n*+, +*--next*+: Force selecting the tab after the current tab.
|
||||
* +*-o*+, +*--opposite*+: Force selecting the tab in the opposite direction of what's configured in 'tabs->select-on-remove'.
|
||||
|
||||
|
||||
|
@ -179,12 +179,12 @@ class CommandDispatcher:
|
||||
raise cmdexc.CommandError("Last focused tab vanished!")
|
||||
self._set_current_index(idx)
|
||||
|
||||
def _get_selection_override(self, left, right, opposite):
|
||||
def _get_selection_override(self, prev, next_, opposite):
|
||||
"""Helper function for tab_close to get the tab to select.
|
||||
|
||||
Args:
|
||||
left: Force selecting the tab to the left of the current tab.
|
||||
right: Force selecting the tab to the right of the current tab.
|
||||
prev: Force selecting the tab before the current tab.
|
||||
next_: Force selecting the tab after the current tab.
|
||||
opposite: Force selecting the tab in the opposite direction of
|
||||
what's configured in 'tabs->select-on-remove'.
|
||||
|
||||
@ -192,10 +192,10 @@ class CommandDispatcher:
|
||||
QTabBar.SelectLeftTab, QTabBar.SelectRightTab, or None if no change
|
||||
should be made.
|
||||
"""
|
||||
cmdutils.check_exclusive((left, right, opposite), 'lro')
|
||||
if left:
|
||||
cmdutils.check_exclusive((prev, next_, opposite), 'pno')
|
||||
if prev:
|
||||
return QTabBar.SelectLeftTab
|
||||
elif right:
|
||||
elif next_:
|
||||
return QTabBar.SelectRightTab
|
||||
elif opposite:
|
||||
conf_selection = config.get('tabs', 'select-on-remove')
|
||||
@ -206,7 +206,7 @@ class CommandDispatcher:
|
||||
elif conf_selection == QTabBar.SelectPreviousTab:
|
||||
raise cmdexc.CommandError(
|
||||
"-o is not supported with 'tabs->select-on-remove' set to "
|
||||
"'previous'!")
|
||||
"'last-used'!")
|
||||
else: # pragma: no cover
|
||||
raise ValueError("Invalid select-on-remove value "
|
||||
"{!r}!".format(conf_selection))
|
||||
@ -214,12 +214,12 @@ class CommandDispatcher:
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||
@cmdutils.argument('count', count=True)
|
||||
def tab_close(self, left=False, right=False, opposite=False, count=None):
|
||||
def tab_close(self, prev=False, next_=False, opposite=False, count=None):
|
||||
"""Close the current/[count]th tab.
|
||||
|
||||
Args:
|
||||
left: Force selecting the tab to the left of the current tab.
|
||||
right: Force selecting the tab to the right of the current tab.
|
||||
prev: Force selecting the tab before the current tab.
|
||||
next_: Force selecting the tab after the current tab.
|
||||
opposite: Force selecting the tab in the opposite direction of
|
||||
what's configured in 'tabs->select-on-remove'.
|
||||
count: The tab index to close, or None
|
||||
@ -228,7 +228,7 @@ class CommandDispatcher:
|
||||
if tab is None:
|
||||
return
|
||||
tabbar = self._tabbed_browser.tabBar()
|
||||
selection_override = self._get_selection_override(left, right,
|
||||
selection_override = self._get_selection_override(prev, next_,
|
||||
opposite)
|
||||
if selection_override is None:
|
||||
self._tabbed_browser.close_tab(tab)
|
||||
|
@ -1781,4 +1781,9 @@ CHANGED_KEY_COMMANDS = [
|
||||
|
||||
(re.compile(r'^prompt-yes$'), r'prompt-accept yes'),
|
||||
(re.compile(r'^prompt-no$'), r'prompt-accept no'),
|
||||
|
||||
(re.compile(r'^tab-close -l$'), 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 --right$'), r'tab-close --next'),
|
||||
]
|
||||
|
@ -70,24 +70,24 @@ Feature: Tab management
|
||||
- data/numbers/3.txt
|
||||
- data/numbers/4.txt (active)
|
||||
|
||||
Scenario: :tab-close with select-on-remove = prev and --right
|
||||
Scenario: :tab-close with select-on-remove = prev and --next
|
||||
When I set tabs -> select-on-remove to prev
|
||||
And 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-close --right
|
||||
And I run :tab-close --next
|
||||
Then the following tabs should be open:
|
||||
- data/numbers/1.txt
|
||||
- data/numbers/3.txt (active)
|
||||
|
||||
Scenario: :tab-close with select-on-remove = next and --left
|
||||
Scenario: :tab-close with select-on-remove = next and --prev
|
||||
When I set tabs -> select-on-remove to next
|
||||
And 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-close --left
|
||||
And I run :tab-close --prev
|
||||
Then the following tabs should be open:
|
||||
- data/numbers/1.txt (active)
|
||||
- data/numbers/3.txt
|
||||
@ -126,7 +126,7 @@ Feature: Tab management
|
||||
And I open data/numbers/3.txt in a new tab
|
||||
And I open data/numbers/4.txt in a new tab
|
||||
And I run :tab-focus 2
|
||||
And I run :tab-close --left
|
||||
And I run :tab-close --prev
|
||||
And I run :tab-focus 2
|
||||
And I run :tab-close
|
||||
Then the following tabs should be open:
|
||||
|
Loading…
Reference in New Issue
Block a user