Skip to content

Commit

Permalink
Merge pull request #4717 from axxag/master
Browse files Browse the repository at this point in the history
Fix autoFix on save (source.fixAll.csharp)
  • Loading branch information
JoeRobich authored Aug 24, 2021
2 parents 0f41f75 + 13a0778 commit b09b43f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/features/fixAllProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/omnisharp/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit b09b43f

Please sign in to comment.