diff --git a/src/features/fixAllProvider.ts b/src/features/fixAllProvider.ts index 1299755b0..aa010c02c 100644 --- a/src/features/fixAllProvider.ts +++ b/src/features/fixAllProvider.ts @@ -15,6 +15,13 @@ import { buildEditForResponse } from '../omnisharp/fileOperationsResponseEditBui import { CancellationToken } from 'vscode-languageserver-protocol'; export class FixAllProvider extends AbstractProvider implements vscode.CodeActionProvider { + public static fixAllCodeActionKind = + vscode.CodeActionKind.SourceFixAll.append('csharp'); + + public static metadata: vscode.CodeActionProviderMetadata = { + providedCodeActionKinds: [FixAllProvider.fixAllCodeActionKind] + }; + public constructor(private server: OmniSharpServer, languageMiddlewareFeature: LanguageMiddlewareFeature) { super(server, languageMiddlewareFeature); let disposable = new CompositeDisposable(); @@ -35,7 +42,7 @@ export class FixAllProvider extends AbstractProvider implements vscode.CodeActio return []; } - if (context.only.value === "source.fixAll.csharp") { + if (context.only.contains(FixAllProvider.fixAllCodeActionKind)) { await this.applyFixes(document.fileName, FixAllScope.Document, undefined); } diff --git a/src/omnisharp/extension.ts b/src/omnisharp/extension.ts index 86a7d34ee..a50f1abae 100644 --- a/src/omnisharp/extension.ts +++ b/src/omnisharp/extension.ts @@ -103,7 +103,7 @@ export async function activate(context: vscode.ExtensionContext, packageJSON: an // so that it will be cleaned up if OmniSharp is restarted. const fixAllProvider = new FixAllProvider(server, languageMiddlewareFeature); localDisposables.add(fixAllProvider); - localDisposables.add(vscode.languages.registerCodeActionsProvider(documentSelector, fixAllProvider)); + localDisposables.add(vscode.languages.registerCodeActionsProvider(documentSelector, fixAllProvider, FixAllProvider.metadata)); localDisposables.add(reportDiagnostics(server, advisor, languageMiddlewareFeature)); localDisposables.add(forwardChanges(server)); localDisposables.add(trackVirtualDocuments(server, eventStream));