mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Sort active tabs instead of directly using active_tab_history
Ensures current active tab is preserved and remaining tabs are created in active history order
This commit is contained in:
@@ -1187,11 +1187,14 @@ class TabManager: # {{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
def serialize_state_as_session(self) -> list[str]:
|
def serialize_state_as_session(self) -> list[str]:
|
||||||
tmap = {tab.id: tab for tab in self}
|
|
||||||
ans = []
|
ans = []
|
||||||
for tab_id in self.active_tab_history or tmap:
|
hmap = {tab_id: i for i, tab_id in enumerate(self.active_tab_history)}
|
||||||
tab = tmap.get(tab_id)
|
at = self.active_tab
|
||||||
if tab is not None:
|
def skey(tab: Tab) -> int:
|
||||||
|
if tab is at:
|
||||||
|
return len(self.active_tab_history) + 1
|
||||||
|
return hmap.get(tab.id, -1)
|
||||||
|
for tab in sorted(self, key=skey):
|
||||||
ans.extend(tab.serialize_state_as_session())
|
ans.extend(tab.serialize_state_as_session())
|
||||||
if ans:
|
if ans:
|
||||||
prefix = ['new_os_window']
|
prefix = ['new_os_window']
|
||||||
|
|||||||
Reference in New Issue
Block a user