When serializing windows in a tab keep the window order

This is needed because layouts other than split use the window
order to position windows.

Maybe should serialize active history in layout state, but I dont think
it's that important.
This commit is contained in:
Kovid Goyal 2025-08-12 18:45:23 +05:30
parent 3aff57933a
commit 214dc73c52
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 8 deletions

View file

@ -292,13 +292,17 @@ class Tab: # {{{
def serialize_state_as_session(self) -> list[str]:
import shlex
launch_cmds = []
for g in self.windows.iter_groups_in_activation_order():
active_idx = self.windows.active_group_idx
for i, g in enumerate(self.windows.iter_all_layoutable_groups()):
gw: list[str] = []
for window in g:
lc = window.as_launch_command(is_overlay=bool(gw))
if lc:
gw.append(shlex.join(lc))
launch_cmds.extend(gw)
if gw:
launch_cmds.extend(gw)
if i == active_idx:
launch_cmds.append('focus')
if launch_cmds:
return [
f'new_tab {self.name}'.rstrip(),

View file

@ -333,12 +333,6 @@ class WindowList:
return
self.set_active_group_idx(len(self.groups) - 1, notify=notify)
def iter_groups_in_activation_order(self) -> Iterator[WindowGroup]:
imap = {gid: i for i, gid in enumerate(self.active_group_history)}
def skey(g: WindowGroup) -> int:
return imap.get(g.id, -1)
yield from sorted(self.groups, key=skey)
@property
def num_groups(self) -> int:
return len(self.groups)