Apply auto fix on save actions sequentially and make sure we request fixes of the specific type we are interested in

This commit is contained in:
Matt Bierner
2019-01-21 17:10:25 -08:00
parent 2ebdac4afd
commit c994fc20fa
3 changed files with 22 additions and 15 deletions

View File

@@ -38,7 +38,7 @@ class TypeScriptAutoFixProvider implements vscode.CodeActionProvider {
context: vscode.CodeActionContext,
token: vscode.CancellationToken
): Promise<vscode.CodeAction[] | undefined> {
if (!context.only || !context.only.contains(vscode.CodeActionKind.Source)) {
if (!context.only || !(context.only.contains(vscode.CodeActionKind.SourceAutoFix) || vscode.CodeActionKind.SourceAutoFix.contains(context.only))) {
return undefined;
}

View File

@@ -82,14 +82,14 @@ export class OrganizeImportsCodeActionProvider implements vscode.CodeActionProvi
return [];
}
if (!context.only || !context.only.contains(vscode.CodeActionKind.SourceOrganizeImports)) {
if (!context.only || !(context.only.contains(vscode.CodeActionKind.SourceOrganizeImports) || vscode.CodeActionKind.SourceOrganizeImports.contains(context.only))) {
return [];
}
this.fileConfigManager.ensureConfigurationForDocument(document, token);
const action = new vscode.CodeAction(
localize('oraganizeImportsAction.title', "Organize Imports"),
localize('organizeImportsAction.title', "Organize Imports"),
vscode.CodeActionKind.SourceOrganizeImports);
action.command = { title: '', command: OrganizeImportsCommand.Id, arguments: [file] };
return [action];