@@ -99,10 +99,12 @@ pluto_server_options = Pluto.Configuration.from_flat_kwargs(;
9999 # show_file_system=false,
100100 dismiss_update_notification = true ,
101101 auto_reload_from_file = false ,
102+ disable_writing_notebook_files = true ,
102103 (Symbol (k) => v for (k, v) in JSON. parse (pluto_launch_params)). .. )
104+
103105pluto_server_session = Pluto. ServerSession (;
104106 secret = secret,
105- options = pluto_server_options
107+ options = pluto_server_options,
106108)
107109
108110extensionData = PlutoExtensionSessionData (
@@ -118,6 +120,21 @@ function whenNotebookUpdates(path, newString)
118120 sendCommand (path, newString)
119121end
120122
123+ function event_listener (pe:: Pluto.PlutoEvent )
124+ @info " Overriden PlutoEvent for" pe. path
125+ end
126+
127+ function event_listener (pe:: Pluto.FileSaveEvent )
128+ @info " Overriden filesave event for" pe. path
129+ id = string (pe. notebook. notebook_id)
130+ oldContent = get (extensionData. textRepresentations, id, " " )
131+ if oldContent != pe. fileContent
132+ whenNotebookUpdates (pe. path, pe. fileContent)
133+ extensionData. textRepresentations[id] = pe. fileContent
134+ end
135+ end
136+
137+ extensionData. session. event_listener = event_listener
121138# ##
122139@info " OPEN NOTEBOOK"
123140
@@ -168,16 +185,6 @@ try ## Note: This is to assist with co-developing Pluto & this Extension
168185catch
169186end
170187
171- function registerOnFileSaveListener (notebook:: Pluto.Notebook )
172- function onfilechange (pe:: Pluto.PlutoEvent )
173- if pe isa Pluto. FileSaveEvent
174- whenNotebookUpdates (pe. path, pe. fileContent)
175- end
176- end
177- notebook. write_out_fs = false
178- notebook. listeners = [onfilechange, notebook. listeners... ]
179- end
180-
181188command_task = Pluto. @asynclog while true
182189 filenbmap = extensionData. notebooks
183190 new_command = getNextSTDINCommand ()
@@ -202,7 +209,6 @@ command_task = Pluto.@asynclog while true
202209
203210 jlpath = detail[" fsPath" ] # joinpath(extensionData.jlfilesroot, detail["jlfile"])
204211 nb = Pluto. SessionActions. open (pluto_server_session, jlpath; notebook_id = UUID (detail[" notebook_id" ]))
205- registerOnFileSaveListener (nb)
206212 filenbmap[detail[" jlfile" ]] = nb
207213 generate_output (nb, editor_html_filename, vscode_proxy_root, frontend_params)
208214
0 commit comments