From cdce0bfddbfede2a59d4bb48e511a7f2995180d1 Mon Sep 17 00:00:00 2001 From: zjhmale Date: Fri, 24 Mar 2017 11:39:53 +0800 Subject: [PATCH] Fixes #25 --- src/controller.js | 7 ++++++- src/extension.js | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/controller.js b/src/controller.js index ff02a10..98f400d 100644 --- a/src/controller.js +++ b/src/controller.js @@ -37,6 +37,10 @@ let withCompilerOptions = (callback) => { }) } +let typeCheckOnSave = () => { + withCompilerOptions(commands.typecheckFile) +} + let runCommand = (command) => { return (_) => { withCompilerOptions(command) @@ -47,5 +51,6 @@ module.exports = { getCommands, destroy: commands.destroy, diagnosticCollection: commands.diagnosticCollection, - withCompilerOptions: withCompilerOptions + withCompilerOptions: withCompilerOptions, + typeCheckOnSave: typeCheckOnSave } diff --git a/src/extension.js b/src/extension.js index aaebbe0..ec3df0e 100644 --- a/src/extension.js +++ b/src/extension.js @@ -19,6 +19,10 @@ function activate(context) { } }) + vscode.workspace.onDidSaveTextDocument((event) => { + controller.typeCheckOnSave() + }) + context.subscriptions.push(controller.diagnosticCollection) controller.getCommands().forEach(([key, value]) => { let disposable = vscode.commands.registerCommand(key, value)