55
66from .captions import caption_for_sheet_identities
77from .constants import TAB_HISTORY_LIMIT
8- from .sheets import SheetIdentity , sheet_identity
8+ from .sheets import SheetIdentity , identities_have_dirty_sheet , sheet_identity
99from .state import GroupSelectionState , SheetSelectionHistory
1010
1111
1212@dataclass
1313class Entry :
1414 selection : GroupSelectionState
1515 caption : list [str ]
16+ dirty : bool = False
1617
1718
1819def collect_entries (window , history : SheetSelectionHistory ) -> list [Entry ]:
@@ -23,10 +24,12 @@ def collect_entries(window, history: SheetSelectionHistory) -> list[Entry]:
2324 group_state_stack = history ["groups" ].get (str (active_group ))
2425 if group_state_stack :
2526 for group_state in group_state_stack :
27+ identities = group_state ["selected_sheets" ]
2628 entries .append (
2729 Entry (
2830 selection = group_state ,
29- caption = caption_for_sheet_identities (group_state ["selected_sheets" ], window ),
31+ caption = caption_for_sheet_identities (identities , window ),
32+ dirty = identities_have_dirty_sheet (identities , window , active_group ),
3033 )
3134 )
3235 seen_identities .update (_selection_identity_keys (group_state ))
@@ -38,20 +41,21 @@ def collect_entries(window, history: SheetSelectionHistory) -> list[Entry]:
3841 if identity in seen_identities :
3942 continue
4043
41- entries .append (_entry_for_sheet (sheet , window ))
44+ entries .append (_entry_for_sheet (sheet , window , active_group ))
4245 seen_identities .add (identity )
4346
4447 return entries
4548
4649
47- def _entry_for_sheet (sheet , window ) -> Entry :
50+ def _entry_for_sheet (sheet , window , group : int ) -> Entry :
4851 identity = sheet_identity (sheet , window )
4952 return Entry (
5053 selection = {
5154 "active_sheet_index" : 0 ,
5255 "selected_sheets" : [identity ],
5356 },
5457 caption = caption_for_sheet_identities ([identity ], window ),
58+ dirty = identities_have_dirty_sheet ([identity ], window , group ),
5559 )
5660
5761
0 commit comments