Skip to content

Commit 8aa982e

Browse files
committed
Fix #22, break rename/move files, fix Control + S
1 parent 5ae7ce6 commit 8aa982e

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

julia-runtime/run.jl

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pluto_server_options = Pluto.Configuration.from_flat_kwargs(;
9898
launch_browser = false,
9999
# show_file_system=false,
100100
dismiss_update_notification = true,
101-
auto_reload_from_file = true,
101+
auto_reload_from_file = false,
102102
(Symbol(k) => v for (k, v) in JSON.parse(pluto_launch_params))...)
103103
pluto_server_session = Pluto.ServerSession(;
104104
secret = secret,
@@ -113,9 +113,9 @@ extensionData = PlutoExtensionSessionData(
113113
joinpath(asset_output_dir, "jlfiles/")
114114
)
115115

116-
function whenNotebookUpdates(jlfile, newString)
117-
filename = splitpath(jlfile)[end]
118-
sendCommand(filename, newString)
116+
function whenNotebookUpdates(path, newString)
117+
write(path, newString)
118+
sendCommand(path, newString)
119119
end
120120

121121
###
@@ -168,7 +168,7 @@ try ## Note: This is to assist with co-developing Pluto & this Extension
168168
catch
169169
end
170170

171-
function registerOnFileSaveListener(notebook::Pluto.notebook)
171+
function registerOnFileSaveListener(notebook::Pluto.Notebook)
172172
function onfilechange(pe::Pluto.PlutoEvent)
173173
if pe isa Pluto.FileSaveEvent
174174
whenNotebookUpdates(pe.path, pe.fileContent)
@@ -200,28 +200,15 @@ command_task = Pluto.@asynclog while true
200200
end
201201
frontend_params = get(detail, "frontend_params", Dict())
202202

203-
204-
jlpath = joinpath(extensionData.jlfilesroot, detail["jlfile"])
205-
extensionData.textRepresentations[detail["jlfile"]] = detail["text"]
206-
open(jlpath, "w") do f
207-
write(f, detail["text"])
208-
end
203+
jlpath = detail["fsPath"] # joinpath(extensionData.jlfilesroot, detail["jlfile"])
209204
nb = Pluto.SessionActions.open(pluto_server_session, jlpath; notebook_id = UUID(detail["notebook_id"]))
210-
211205
registerOnFileSaveListener(nb)
212-
213206
filenbmap[detail["jlfile"]] = nb
214207
generate_output(nb, editor_html_filename, vscode_proxy_root, frontend_params)
215208

216209
elseif type == "update"
217210
nb = filenbmap[detail["jlfile"]]
218-
jlpath = joinpath(extensionData.jlfilesroot, detail["jlfile"])
219-
open(jlpath, "w") do f
220-
write(f, detail["text"])
221-
end
222211
Pluto.update_from_file(pluto_server_session, nb)
223-
extensionData.textRepresentations[detail["jlfile"]] = detail["text"]
224-
225212
elseif type == "shutdown"
226213
nb = get(filenbmap, detail["jlfile"], nothing)
227214
!isnothing(nb) && Pluto.SessionActions.shutdown(

src/PlutoEditor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class PlutoEditor implements vscode.CustomTextEditorProvider {
2121
statusbar.show()
2222
}
2323

24-
constructor(private readonly context: vscode.ExtensionContext) {}
24+
constructor(private readonly context: vscode.ExtensionContext) { }
2525

2626
/**
2727
* Called when our custom editor is opened.
@@ -41,6 +41,7 @@ export class PlutoEditor implements vscode.CustomTextEditorProvider {
4141

4242
const editor_html_filename = `editor_bespoke_${notebook_id}.html`
4343
const jlfile = `editor_bespoke_${notebook_id}.jl`
44+
const fsPath = document.uri.fsPath
4445

4546
this.webviews.add(document, notebook_id, panel)
4647

@@ -103,7 +104,7 @@ export class PlutoEditor implements vscode.CustomTextEditorProvider {
103104
console.log("didsave", panel.active)
104105
if (doc.uri.toString() === document.uri.toString()) {
105106
// When VSCode updates the document, notify pluto from here
106-
backend.send_command("update", { jlfile, text: doc.getText() })
107+
backend.send_command("update", { jlfile })
107108
}
108109
this.renderStatusBar()
109110
}, disposables)
@@ -188,6 +189,7 @@ export class PlutoEditor implements vscode.CustomTextEditorProvider {
188189
notebook_id,
189190
text,
190191
jlfile,
192+
fsPath,
191193
frontend_params: {
192194
// disable_ui: true,
193195
},

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { TextDecoder, TextEncoder } from "util"
66
import { v4 as uuid } from "uuid"
77

88
// this is a commit on the vscode-webview-proxy branch, see https://github.com/fonsp/Pluto.jl/pull/1493
9-
export const PLUTO_BRANCH_NAME = "091769c3df1d1c29bb1d640b62bb18cfc183a78d"
9+
export const PLUTO_BRANCH_NAME = "376b08851906afc9e52e2c09e823de8d7e656675"
1010

1111
/*
1212
HELLO

0 commit comments

Comments
 (0)