Fix a regression in the previous release that caused the incorrect tab to be active when loading a session

Fixes #9025
This commit is contained in:
Kovid Goyal 2025-09-28 21:46:08 +05:30
parent 545db0f68f
commit 16faa1d541
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 4 deletions

View file

@ -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]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -1031,12 +1031,15 @@ def __init__(self, os_window_id: int, args: CLIOptions, wm_class: str, wm_name:
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: