Skip to content

Commit

Permalink
Adding an option to disable diagnostics for unformatted code.
Browse files Browse the repository at this point in the history
  • Loading branch information
belav committed Dec 9, 2024
1 parent 0bec7d2 commit f289bc0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Src/CSharpier.VSCode/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.9.1
- Add option for disabling diagnostics.

## 1.9.0
- Support format selection
- Support for inline highlighting of formatting issues + code actions to format them
Expand Down
5 changes: 5 additions & 0 deletions Src/CSharpier.VSCode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
"default": false,
"description": "Enable debug logs."
},
"csharpier.enableDiagnostics": {
"type": "boolean",
"default": true,
"description": "Enable diagnostics that highlight code that is not formatted with CSharpier."
},
"csharpier.dev.customPath": {
"type": "string",
"default": "",
Expand Down
4 changes: 3 additions & 1 deletion Src/CSharpier.VSCode/src/DiagnosticsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Difference, generateDifferences, showInvisibles } from "prettier-linter
import { FixAllCodeActionsCommand } from "./FixAllCodeActionCommand";
import { Logger } from "./Logger";
import { FormatDocumentProvider } from "./FormatDocumentProvider";
import {workspace} from "vscode";

const DIAGNOSTICS_ID = "csharpier";
const DIAGNOSTICS_SOURCE_ID = "diagnostic";
Expand Down Expand Up @@ -54,7 +55,8 @@ export class DiagnosticsService implements vscode.CodeActionProvider, vscode.Dis
public async runDiagnostics(document: vscode.TextDocument): Promise<void> {
const shouldRunDiagnostics =
this.documentSelector.some(selector => selector.language === document.languageId) &&
!!vscode.workspace.getWorkspaceFolder(document.uri);
!!vscode.workspace.getWorkspaceFolder(document.uri) &&
(workspace.getConfiguration("csharpier").get<boolean>("enableDiagnostics") ?? true);
if (shouldRunDiagnostics) {
try {
const diff = await this.getDiff(document);
Expand Down

0 comments on commit f289bc0

Please sign in to comment.