Skip to content

Commit 23785e6

Browse files
committed
Run worksheets after willSave instead of didSave
We were triggering the worksheet run after a `didSave` event. This means that, if the file was unmodified, hitting `<ctrl-s>` would not re-run the worksheet, even though the previous output would disappear. We know run the worksheet after the `willSave` event, which is triggered regardless of the buffer state. This is not an issue for the language server which uses the tree that it has in memory rather than what's on disk at the moment.
1 parent ffced94 commit 23785e6

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

vscode-dotty/src/worksheet.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,16 +325,11 @@ export class WorksheetProvider implements Disposable {
325325
codeLensProvider,
326326
vscode.languages.registerCodeLensProvider(documentSelector, codeLensProvider),
327327
vscode.workspace.onWillSaveTextDocument(event => {
328+
const runWorksheetOnSave = vscode.workspace.getConfiguration("dotty").get("runWorksheetOnSave")
328329
const worksheet = this.worksheetFor(event.document)
329330
if (worksheet) {
330331
event.waitUntil(Promise.resolve(worksheet.prepareRun()))
331-
}
332-
}),
333-
vscode.workspace.onDidSaveTextDocument(document => {
334-
const runWorksheetOnSave = vscode.workspace.getConfiguration("dotty").get("runWorksheetOnSave")
335-
const worksheet = this.worksheetFor(document)
336-
if (runWorksheetOnSave && worksheet) {
337-
worksheet.run()
332+
if (runWorksheetOnSave) worksheet.run()
338333
}
339334
}),
340335
vscode.workspace.onDidCloseTextDocument(document => {

0 commit comments

Comments
 (0)