Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an option to disable diagnostics for unformatted code. #1404

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading