@@ -392,6 +392,7 @@ class Outputs:
392392 libraryListSource = \
393393 Setting ([Script ("Hello world" , "print('Hello world')\n " )])
394394 currentScriptIndex = Setting (0 )
395+ scriptText = Setting (None , schema_only = True )
395396 splitterState = Setting (None )
396397
397398 class Error (OWWidget .Error ):
@@ -516,6 +517,9 @@ def __init__(self):
516517
517518 select_row (self .libraryView , self .currentScriptIndex )
518519
520+ self .restoreScriptText ()
521+ self .text .textChanged .connect (self .saveScriptText ) # after restoring
522+
519523 self .splitCanvas .setSizes ([2 , 1 ])
520524 if self .splitterState is not None :
521525 self .splitCanvas .restoreState (QByteArray (self .splitterState ))
@@ -524,6 +528,16 @@ def __init__(self):
524528 self .controlArea .layout ().addStretch (1 )
525529 self .resize (800 , 600 )
526530
531+ def restoreScriptText (self ):
532+ if self .scriptText is not None :
533+ current = self .text .toPlainText ()
534+ # do not mark scripts as modified
535+ if self .scriptText != current :
536+ self .text .document ().setPlainText (self .scriptText )
537+
538+ def saveScriptText (self ):
539+ self .scriptText = self .text .toPlainText ()
540+
527541 def handle_input (self , obj , id , signal ):
528542 id = id [0 ]
529543 dic = getattr (self , signal )
0 commit comments