mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-06-25 10:27:24 +00:00
Fix move_tab_forward/backward with tab_bar_filter
When tab_bar_filter is used (e.g. with sessions), move_tab() was using self.active_tab_idx (index in the full tabs list) as an index into the filtered tabs list, causing incorrect behavior. Also fix the same bug in tab_at_location() for left/right locations. Fixes #9672 Fixes #9673
This commit is contained in:
parent
40f9945ea7
commit
780b4337e4
1 changed files with 15 additions and 4 deletions
|
|
@ -1337,8 +1337,13 @@ class TabManager: # {{{
|
|||
return self.tab_for_id(self.active_tab_history[-1])
|
||||
elif loc in ('left', 'right'):
|
||||
delta = -1 if loc == 'left' else 1
|
||||
idx = (len(tabs) + self.active_tab_idx + delta) % len(tabs)
|
||||
return tabs[idx]
|
||||
if (at := self.active_tab) is not None:
|
||||
try:
|
||||
active_idx = tabs.index(at)
|
||||
except ValueError:
|
||||
return None
|
||||
idx = (len(tabs) + active_idx + delta) % len(tabs)
|
||||
return tabs[idx]
|
||||
return None
|
||||
|
||||
def goto_tab(self, tab_num: int) -> None:
|
||||
|
|
@ -1439,8 +1444,14 @@ class TabManager: # {{{
|
|||
def move_tab(self, delta: int = 1) -> None:
|
||||
tabs = tuple(self.tabs_to_be_shown_in_tab_bar)
|
||||
if len(tabs) > 1:
|
||||
idx = self.active_tab_idx
|
||||
new_active_tab = tabs[(idx + len(tabs) + delta) % len(tabs)]
|
||||
if (at := self.active_tab) is None:
|
||||
return
|
||||
try:
|
||||
filtered_idx = tabs.index(at)
|
||||
except ValueError:
|
||||
return
|
||||
new_active_tab = tabs[(filtered_idx + len(tabs) + delta) % len(tabs)]
|
||||
idx = self.tabs.index(at)
|
||||
nidx = self.tabs.index(new_active_tab)
|
||||
step = 1 if idx < nidx else -1
|
||||
for i in range(idx, nidx, step):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue