Add a new --no-last flag to :tab-focus
--no-last prevents going to the last focused tab if a new tab does not need to be focused.
This commit is contained in:
parent
79935e048c
commit
d7a436568c
@ -519,8 +519,7 @@ Show help about a command or setting.
|
||||
|
||||
[[hint]]
|
||||
=== hint
|
||||
Syntax: +:hint [*--mode* 'mode'] [*--add-history*] [*--rapid*]
|
||||
['group'] ['target'] ['args' ['args' ...]]+
|
||||
Syntax: +:hint [*--mode* 'mode'] [*--add-history*] [*--rapid*] ['group'] ['target'] ['args' ['args' ...]]+
|
||||
|
||||
Start hinting.
|
||||
|
||||
@ -770,8 +769,7 @@ Do nothing.
|
||||
|
||||
[[open]]
|
||||
=== open
|
||||
Syntax: +:open [*--related*] [*--bg*] [*--tab*] [*--window*] [*--secure*] [*--private*]
|
||||
['url']+
|
||||
Syntax: +:open [*--related*] [*--bg*] [*--tab*] [*--window*] [*--secure*] [*--private*] ['url']+
|
||||
|
||||
Open a URL in the current/[count]th tab.
|
||||
|
||||
@ -1091,9 +1089,7 @@ Load a session.
|
||||
|
||||
[[session-save]]
|
||||
=== session-save
|
||||
Syntax: +:session-save [*--current*] [*--quiet*] [*--force*] [*--only-active-window*]
|
||||
[*--with-private*]
|
||||
['name']+
|
||||
Syntax: +:session-save [*--current*] [*--quiet*] [*--force*] [*--only-active-window*] [*--with-private*] ['name']+
|
||||
|
||||
Save a session.
|
||||
|
||||
@ -1212,7 +1208,7 @@ The tab index to close
|
||||
|
||||
[[tab-focus]]
|
||||
=== tab-focus
|
||||
Syntax: +:tab-focus ['index']+
|
||||
Syntax: +:tab-focus [*--no-last*] ['index']+
|
||||
|
||||
Select the tab given as argument/[count].
|
||||
|
||||
@ -1224,6 +1220,9 @@ If neither count nor index are given, it behaves like tab-next. If both are give
|
||||
last tab.
|
||||
|
||||
|
||||
==== optional arguments
|
||||
* +*-n*+, +*--no-last*+: Whether to avoid focusing last tab if already focused.
|
||||
|
||||
==== count
|
||||
The tab index to focus, starting with 1.
|
||||
|
||||
|
@ -1109,7 +1109,8 @@ class CommandDispatcher:
|
||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||
@cmdutils.argument('index', choices=['last'])
|
||||
@cmdutils.argument('count', count=True)
|
||||
def tab_focus(self, index: typing.Union[str, int] = None, count=None):
|
||||
def tab_focus(self, index: typing.Union[str, int] = None,
|
||||
count=None, no_last=False):
|
||||
"""Select the tab given as argument/[count].
|
||||
|
||||
If neither count nor index are given, it behaves like tab-next.
|
||||
@ -1121,13 +1122,14 @@ class CommandDispatcher:
|
||||
Negative indices count from the end, such that -1 is the
|
||||
last tab.
|
||||
count: The tab index to focus, starting with 1.
|
||||
no_last: Whether to avoid focusing last tab if already focused.
|
||||
"""
|
||||
index = count if count is not None else index
|
||||
|
||||
if index == 'last':
|
||||
self._tab_focus_last()
|
||||
return
|
||||
elif index == self._current_index() + 1:
|
||||
elif not no_last and index == self._current_index() + 1:
|
||||
self._tab_focus_last(show_error=False)
|
||||
return
|
||||
elif index is None:
|
||||
|
Loading…
Reference in New Issue
Block a user