diff --git a/docs/changelog.rst b/docs/changelog.rst index 7b61e8a39..70dd94eef 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/tabs.py b/kitty/tabs.py index 2714e2f34..cc9057d6c 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -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)