Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
Removed "checkOnSave", "checkWith". Added "actionOnSave"
Browse files Browse the repository at this point in the history
Fixed #10
  • Loading branch information
KalitaAlexey committed Dec 23, 2016
1 parent 36df3d0 commit efd51d9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 27 deletions.
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,17 @@
"default": false,
"description": "Turn on/off autoformatting file on save"
},
"rust.checkOnSave": {
"type": "boolean",
"default": false,
"description": "Turn on/off autochecking file on save using cargo check"
},
"rust.checkWith": {
"rust.actionOnSave": {
"type": "string",
"default": "check",
"description": "Choose between check, check-lib, clippy, build and test to lint"
"default": null,
"enum": [
"build",
"check",
"clippy",
"run",
"test",
null
]
},
"rust.buildArgs": {
"type": "array",
Expand Down
47 changes: 28 additions & 19 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,35 @@ export function activate(ctx: vscode.ExtensionContext): void {
});
}

if (rustConfig['checkOnSave']) {
formatPromise.then(() => {
switch (rustConfig['checkWith']) {
case 'clippy':
vscode.commands.executeCommand('rust.cargo.clippy');
break;
case 'build':
vscode.commands.executeCommand('rust.cargo.build.debug');
break;
case 'check-lib':
vscode.commands.executeCommand('rust.cargo.check.lib');
break;
case 'test':
vscode.commands.executeCommand('rust.cargo.test.debug');
break;
default:
vscode.commands.executeCommand('rust.cargo.check');
}
});
const actionOnSave: string | null = rustConfig['actionOnSave'];

if (actionOnSave === null) {
return;
}

let command: string;

switch (actionOnSave) {
case 'build':
command = 'rust.cargo.build.debug';
break;
case 'check':
command = 'rust.cargo.check';
break;
case 'clippy':
command = 'rust.cargo.clippy';
break;
case 'run':
command = 'rust.cargo.run.debug';
break;
case 'test':
command = 'rust.cargo.test.debug';
break;
}

formatPromise.then(() => {
vscode.commands.executeCommand(command);
});
}));

// Watch for configuration changes for ENV
Expand Down

0 comments on commit efd51d9

Please sign in to comment.