Skip to content

Commit

Permalink
Adding an option to disable diagnostics for unformatted code. (belav#…
Browse files Browse the repository at this point in the history
…1404)

relates to belav#1402 and belav#1403
  • Loading branch information
belav authored and pisolofin committed Dec 14, 2024
1 parent e64588e commit 7f54053
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
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
7 changes: 6 additions & 1 deletion Src/CSharpier.VSCode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "csharpier-vscode",
"displayName": "CSharpier - Code formatter",
"description": "Code formatter using csharpier",
"version": "1.9.0",
"version": "1.9.1",
"publisher": "csharpier",
"author": "CSharpier",
"homepage": "https://marketplace.visualstudio.com/items?itemName=csharpier.csharpier-vscode",
Expand Down 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 7f54053

Please sign in to comment.