From 16faa1d541945acfa8975dd4da356ba1d9622536 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 28 Sep 2025 21:46:08 +0530 Subject: [PATCH] Fix a regression in the previous release that caused the incorrect tab to be active when loading a session Fixes #9025 --- docs/changelog.rst | 3 +++ kitty/tabs.py | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index f81db0230..5b2a0a788 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -141,6 +141,9 @@ Detailed list of changes running in the release build versus the build from source. Also fix using a transparent titlebar causing the background opacity to be darkened. +- Fix a regression in the previous release that caused the incorrect tab to be + active when loading a session (:iss:`9025`) + 0.43.0 [2025-09-28] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/tabs.py b/kitty/tabs.py index eabf724b6..95135fa9f 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -1031,12 +1031,15 @@ class TabManager: # {{{ self.add_tabs_from_session(startup_session) def add_tabs_from_session(self, session: SessionType, session_name: str = '') -> None: - before = len(self.tabs) - for t in session.tabs: + active_tab = self.active_tab + for i, t in enumerate(session.tabs): tab = Tab(self, session_tab=t, session_name=session_name or self.created_in_session_name) self._add_tab(tab) - num_added = len(self.tabs) - before - self._set_active_tab(max(0, min(num_added + session.active_tab_idx, len(self.tabs) - 1))) + if i == session.active_tab_idx: + active_tab = tab + if active_tab is not None: + idx = self.tabs.index(active_tab) + self._set_active_tab(idx) @property def active_tab_idx(self) -> int: