mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-17 14:04:52 +02:00
Allow jumping to the nth previous active tab via goto_tab
This matches the docs for the goto_tab action and there is no reason not to have this. For backwards compat 0 and -1 both go to the first previously active tab as before. However -2 goes to the second previously active tab, -3 to the third and so on.
This commit is contained in:
@@ -79,6 +79,8 @@ Detailed list of changes
|
||||
|
||||
- Linux: Fix a regression in 0.36.0 that caused font features defined via fontconfig to be ignored (:iss:`7773`)
|
||||
|
||||
- :ac:`goto_tab`: Allow numbers less than ``-1`` to go to the Nth previously active tab
|
||||
|
||||
0.36.1 [2024-08-24]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -3968,8 +3968,9 @@ map('Set tab title',
|
||||
egr('''
|
||||
You can also create shortcuts to go to specific :term:`tabs <tab>`, with
|
||||
:code:`1` being the first tab, :code:`2` the second tab and :code:`-1` being the
|
||||
previously active tab, and any number larger than the last tab being the last
|
||||
tab::
|
||||
previously active tab, :code:`-2` being the tab active before the previously active tab and so on.
|
||||
Any number larger than the number of tabs goes to the last tab and any number less
|
||||
than the number of previously used tabs in the history goes to the oldest previously used tab in the history::
|
||||
|
||||
map ctrl+alt+1 goto_tab 1
|
||||
map ctrl+alt+2 goto_tab 2
|
||||
|
||||
@@ -145,8 +145,10 @@ def open_url_parse(func: str, rest: str) -> FuncArgsType:
|
||||
|
||||
@func_with_args('goto_tab')
|
||||
def goto_tab_parse(func: str, rest: str) -> FuncArgsType:
|
||||
args = (max(0, int(rest)), )
|
||||
return func, args
|
||||
n = int(rest)
|
||||
if n < 0:
|
||||
n += 1 # goto_tab subtracts 1 from its argument, this maps both zero and -1 to previous tab for backwards compat.
|
||||
return func, (n,)
|
||||
|
||||
|
||||
@func_with_args('detach_window')
|
||||
|
||||
@@ -1034,11 +1034,11 @@ class TabManager: # {{{
|
||||
tab_num = max(0, len(self.tabs) - 1)
|
||||
if tab_num >= 0:
|
||||
self.set_active_tab_idx(tab_num)
|
||||
else:
|
||||
elif self.active_tab_history:
|
||||
try:
|
||||
old_active_tab_id = self.active_tab_history[tab_num]
|
||||
except IndexError:
|
||||
return
|
||||
old_active_tab_id = self.active_tab_history[0]
|
||||
for idx, tab in enumerate(self.tabs):
|
||||
if tab.id == old_active_tab_id:
|
||||
self.set_active_tab_idx(idx)
|
||||
|
||||
Reference in New Issue
Block a user