@@ -88,6 +88,9 @@ def __init__(self, window: Window, indentType="spaces"):
8888 self .autocomplete_engine = PythonAutocompleteEngine (self )
8989 self .autocomplete_engine .refresh ()
9090
91+ # trigger save indicator
92+ self .modificationChanged .connect (self .saveIndicTrigger )
93+
9194 # Autocompletion
9295 self .setAutoCompletionSource (QsciScintilla .AutoCompletionSource .AcsAPIs )
9396 self .setAutoCompletionThreshold (1 )
@@ -241,6 +244,27 @@ def keyPressEvent(self, event: QKeyEvent):
241244 def show_autocompletion (self ):
242245 self .autocomplete_engine .trigger (force = True )
243246
247+ def saveIndicTrigger (self , modified ):
248+ window_inst = self .window ()
249+ # Find the parent container instead of self
250+ container = self .parentWidget ()
251+ index = window_inst .tab_widget .indexOf (container )
252+
253+ if index == - 1 :
254+ return # Safety check: Tab not found
255+
256+ current_title = window_inst .tab_widget .tabText (index )
257+
258+ if modified :
259+ # Add the star if it's not already there
260+ if not current_title .endswith (" *" ):
261+ window_inst .tab_widget .setTabText (index , f"{ current_title } *" )
262+ else :
263+ # Remove the star if it is there
264+ if current_title .endswith (" *" ):
265+ window_inst .tab_widget .setTabText (index , current_title [:- 2 ])
266+
267+
244268 def show_context_menu (self , point ):
245269 self .context_menu .popup (self .mapToGlobal (point ))
246270
0 commit comments