From 23785e6bd3649ff0d2750da42c67bcbb0c56d71c Mon Sep 17 00:00:00 2001 From: Martin Duhem Date: Sat, 1 Dec 2018 14:52:06 +0100 Subject: [PATCH] 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 `` 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. --- vscode-dotty/src/worksheet.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/vscode-dotty/src/worksheet.ts b/vscode-dotty/src/worksheet.ts index 974a1a917ba6..a95a854a98f0 100644 --- a/vscode-dotty/src/worksheet.ts +++ b/vscode-dotty/src/worksheet.ts @@ -325,16 +325,11 @@ export class WorksheetProvider implements Disposable { codeLensProvider, vscode.languages.registerCodeLensProvider(documentSelector, codeLensProvider), vscode.workspace.onWillSaveTextDocument(event => { + const runWorksheetOnSave = vscode.workspace.getConfiguration("dotty").get("runWorksheetOnSave") const worksheet = this.worksheetFor(event.document) if (worksheet) { event.waitUntil(Promise.resolve(worksheet.prepareRun())) - } - }), - vscode.workspace.onDidSaveTextDocument(document => { - const runWorksheetOnSave = vscode.workspace.getConfiguration("dotty").get("runWorksheetOnSave") - const worksheet = this.worksheetFor(document) - if (runWorksheetOnSave && worksheet) { - worksheet.run() + if (runWorksheetOnSave) worksheet.run() } }), vscode.workspace.onDidCloseTextDocument(document => {