Fix tab bar sometimes showing incorrect tabs when it is filtered to show only tabs from the current session

Fixes #9079
This commit is contained in:
Kovid Goyal 2025-10-07 14:35:13 +05:30
parent 9f9216457e
commit fa808c3b10
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 20 additions and 6 deletions

View file

@ -145,7 +145,10 @@ Detailed list of changes
- Fix a regression in the previous release that broke ``goto_session -1``
- Fix rendering broken on ancient GPU drivers that dont support rendering to 16 bit textures (:iss:`9068`)
- Fix rendering broken on ancient GPU drivers that do not support rendering to 16 bit textures (:iss:`9068`)
- Fix tab bar sometimes showing incorrect tabs when it is filtered to show only
tabs from the current session (:iss:`9079`)
0.43.1 [2025-10-01]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -1388,12 +1388,21 @@ class TabManager: # {{{
while self.active_tab_history and self.active_tab_history[-1] == tab.id:
self.active_tab_history.pop()
def previous_active_tab() -> Tab | None:
while self.active_tab_history:
tab_id = self.active_tab_history.pop()
if tab_id != removed_tab.id:
if (ans := self.tab_for_id(tab_id)) is not None:
return ans
return self.tabs[0] if self.tabs else None
if active_tab_before_removal is removed_tab:
if len(self.tabs) == 0:
self._active_tab_idx = 0
elif len(self.tabs) == 1:
remove_from_end_of_active_history(self.tabs[0])
self._set_active_tab(0, store_in_history=False)
if len(tabs) == 0 or (len(tabs) == 1 and removed_tab is tabs[0]):
tab = previous_active_tab()
if tab is None:
self._active_tab_idx = 0
else:
self._set_active_tab(self.tabs.index(tab), store_in_history=False)
else:
next_active_tab: Tab | None = None
match get_options().tab_switch_strategy:
@ -1401,6 +1410,8 @@ class TabManager: # {{{
while self.active_tab_history and next_active_tab is None:
tab_id = self.active_tab_history.pop()
next_active_tab = self.tab_for_id(tab_id)
if next_active_tab not in tabs:
next_active_tab = None
case 'left':
next_active_tab = tabs[(tabs.index(active_tab_before_removal) - 1 + len(tabs)) % len(tabs)]
remove_from_end_of_active_history(next_active_tab)