diff --git a/julia-runtime/run.jl b/julia-runtime/run.jl index 8c48d4c..f8da436 100644 --- a/julia-runtime/run.jl +++ b/julia-runtime/run.jl @@ -99,10 +99,12 @@ pluto_server_options = Pluto.Configuration.from_flat_kwargs(; # show_file_system=false, dismiss_update_notification = true, auto_reload_from_file = false, + disable_writing_notebook_files = true, (Symbol(k) => v for (k, v) in JSON.parse(pluto_launch_params))...) + pluto_server_session = Pluto.ServerSession(; secret = secret, - options = pluto_server_options + options = pluto_server_options, ) extensionData = PlutoExtensionSessionData( @@ -118,6 +120,31 @@ function whenNotebookUpdates(path, newString) sendCommand(path, newString) end +function event_listener(pe::Pluto.PlutoEvent) + @info "Overriden PlutoEvent for" pe.path +end + +function event_listener(pe::Pluto.FileSaveEvent) + @info "Overriden filesave event for" pe.path + id = string(pe.notebook.notebook_id) + oldContent = get(extensionData.textRepresentations, id, "") + if oldContent != pe.file_contents + whenNotebookUpdates(pe.path, pe.file_contents) + extensionData.textRepresentations[id] = pe.file_contents + end +end + +# function event_listener(pe::Pluto.FileLocalChangeEvent) +# @info "Overriden filesave event for" pe.path +# id = string(pe.notebook.notebook_id) +# oldContent = get(extensionData.textRepresentations, id, "") +# if oldContent != pe.file_contents +# whenNotebookUpdates(pe.path, pe.file_contents) +# extensionData.textRepresentations[id] = pe.file_contents +# end +# end + +extensionData.session.event_listener = event_listener ### @info "OPEN NOTEBOOK" @@ -168,16 +195,6 @@ try ## Note: This is to assist with co-developing Pluto & this Extension catch end -function registerOnFileSaveListener(notebook::Pluto.Notebook) - function onfilechange(pe::Pluto.PlutoEvent) - if pe isa Pluto.FileSaveEvent - whenNotebookUpdates(pe.path, pe.fileContent) - end - end - notebook.write_out_fs = false - notebook.listeners = [onfilechange, notebook.listeners...] -end - command_task = Pluto.@asynclog while true filenbmap = extensionData.notebooks new_command = getNextSTDINCommand() @@ -202,7 +219,6 @@ command_task = Pluto.@asynclog while true jlpath = detail["fsPath"] # joinpath(extensionData.jlfilesroot, detail["jlfile"]) nb = Pluto.SessionActions.open(pluto_server_session, jlpath; notebook_id = UUID(detail["notebook_id"])) - registerOnFileSaveListener(nb) filenbmap[detail["jlfile"]] = nb generate_output(nb, editor_html_filename, vscode_proxy_root, frontend_params) diff --git a/package.json b/package.json index 7e041d4..cf7dbcd 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "pluto-vscode", "displayName": "Pluto.jl (alpha preview)", "description": "Pluto.jl inside VS Code", - "version": "0.1.1", + "version": "0.1.2", "publisher": "juliacomputing", "license": "MIT", "icon": "media/favicon_unsaturated_bg_512.png", diff --git a/src/backend.ts b/src/backend.ts index b690084..186208c 100644 --- a/src/backend.ts +++ b/src/backend.ts @@ -143,13 +143,13 @@ export class PlutoBackend { this._server.listen(await this.localport); this._process.stdout!.on("data", (data) => { - const text = data.slice(0, data.length - 1) + const text = data.slice(0) console.log(`📈${text}`) }) this._process.stderr!.on("data", (data) => { - const text = data.slice(0, data.length - 1) + const text = data.slice(0) console.log(`📈${text}`) // @info prints to stderr diff --git a/src/extension.ts b/src/extension.ts index 4e881e8..80a1cd0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -6,7 +6,7 @@ import { TextDecoder, TextEncoder } from "util" import { v4 as uuid } from "uuid" // this is a commit on the vscode-webview-proxy branch, see https://github.com/fonsp/Pluto.jl/pull/1493 -export const PLUTO_BRANCH_NAME = "376b08851906afc9e52e2c09e823de8d7e656675" +export const PLUTO_BRANCH_NAME = "7f00dfd13ab19204fafa0a58d20c1808d0284d38" /* HELLO