Skip to content

Commit 214dc73

Browse files
committed
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.
1 parent 3aff579 commit 214dc73

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

kitty/tabs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,17 @@ def serialize_state(self) -> dict[str, Any]:
292292
def serialize_state_as_session(self) -> list[str]:
293293
import shlex
294294
launch_cmds = []
295-
for g in self.windows.iter_groups_in_activation_order():
295+
active_idx = self.windows.active_group_idx
296+
for i, g in enumerate(self.windows.iter_all_layoutable_groups()):
296297
gw: list[str] = []
297298
for window in g:
298299
lc = window.as_launch_command(is_overlay=bool(gw))
299300
if lc:
300301
gw.append(shlex.join(lc))
301-
launch_cmds.extend(gw)
302+
if gw:
303+
launch_cmds.extend(gw)
304+
if i == active_idx:
305+
launch_cmds.append('focus')
302306
if launch_cmds:
303307
return [
304308
f'new_tab {self.name}'.rstrip(),

kitty/window_list.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,6 @@ def make_previous_group_active(self, which: int = 1, notify: bool = True) -> Non
333333
return
334334
self.set_active_group_idx(len(self.groups) - 1, notify=notify)
335335

336-
def iter_groups_in_activation_order(self) -> Iterator[WindowGroup]:
337-
imap = {gid: i for i, gid in enumerate(self.active_group_history)}
338-
def skey(g: WindowGroup) -> int:
339-
return imap.get(g.id, -1)
340-
yield from sorted(self.groups, key=skey)
341-
342336
@property
343337
def num_groups(self) -> int:
344338
return len(self.groups)

0 commit comments

Comments
 (0)