Skip to content

Commit 3550089

Browse files
committed
fix(diagnostics): differentiate linter warnings from fatal errors\n\nThis change addresses an issue where linter errors were treated as fatal, causing unnecessary retries and inefficient file writes. The getNewDiagnostics function has been updated to categorize diagnostics into problems (fatal errors) and warnings (linter errors). The DiffViewProvider has been updated to consume this new structure and present the information to the AI in a more structured way.\n\nFixes #4622
1 parent b154492 commit 3550089

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/integrations/diagnostics/__tests__/index.test.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ vi.mock("vscode", async () => {
2121
}
2222
},
2323
Diagnostic: class {
24-
constructor(public range: any, public message: string, public severity: number, public source?: string) {}
24+
range: any;
25+
message: string;
26+
severity: number;
27+
source?: string;
28+
29+
constructor(range: any, message: string, severity: number) {
30+
this.range = range;
31+
this.message = message;
32+
this.severity = severity;
33+
}
2534
},
2635
Uri: {
2736
file: (path: string) => ({
@@ -56,7 +65,7 @@ describe("getNewDiagnostics", () => {
5665
const oldDiagnostics: [vscode.Uri, vscode.Diagnostic[]][] = [];
5766
const newDiagnostics: [vscode.Uri, vscode.Diagnostic[]][] = [
5867
[vscode.Uri.file("/path/to/file1.ts"), [
59-
new vscode.Diagnostic(new vscode.Range(0, 0, 0, 10), "New fatal error", vscode.DiagnosticSeverity.Error, "typescript")
68+
Object.assign(new vscode.Diagnostic(new vscode.Range(0, 0, 0, 10), "New fatal error", vscode.DiagnosticSeverity.Error), { source: "typescript" })
6069
]],
6170
];
6271

@@ -70,7 +79,7 @@ describe("getNewDiagnostics", () => {
7079
const oldDiagnostics: [vscode.Uri, vscode.Diagnostic[]][] = [];
7180
const newDiagnostics: [vscode.Uri, vscode.Diagnostic[]][] = [
7281
[vscode.Uri.file("/path/to/file1.ts"), [
73-
new vscode.Diagnostic(new vscode.Range(0, 0, 0, 10), "New linter warning", vscode.DiagnosticSeverity.Error, "pylance")
82+
Object.assign(new vscode.Diagnostic(new vscode.Range(0, 0, 0, 10), "New linter warning", vscode.DiagnosticSeverity.Error), { source: "pylance" })
7483
]],
7584
];
7685

@@ -84,8 +93,8 @@ describe("getNewDiagnostics", () => {
8493
const oldDiagnostics: [vscode.Uri, vscode.Diagnostic[]][] = [];
8594
const newDiagnostics: [vscode.Uri, vscode.Diagnostic[]][] = [
8695
[vscode.Uri.file("/path/to/file1.ts"), [
87-
new vscode.Diagnostic(new vscode.Range(0, 0, 0, 10), "New fatal error", vscode.DiagnosticSeverity.Error, "typescript"),
88-
new vscode.Diagnostic(new vscode.Range(1, 0, 1, 10), "New linter warning", vscode.DiagnosticSeverity.Error, "eslint")
96+
Object.assign(new vscode.Diagnostic(new vscode.Range(0, 0, 0, 10), "New fatal error", vscode.DiagnosticSeverity.Error), { source: "typescript" }),
97+
Object.assign(new vscode.Diagnostic(new vscode.Range(1, 0, 1, 10), "New linter warning", vscode.DiagnosticSeverity.Error), { source: "eslint" })
8998
]],
9099
];
91100

0 commit comments

Comments
 (0)